以下这些代码是blackfin bf537的LED闪烁程序示例 LED将从右向左闪烁并切换回来。 / ** /
EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;
// shift old LED pattern by one, left to right
if(sLight_Move_Direction)
{
if((ucActive_LED = ucActive_LED >> 1) <= 0x0020) ucActive_LED = 0x1000;
}
else
{
if((ucActive_LED = ucActive_LED << 1) == 0x0020) ucActive_LED = 0x0020;
}
// write new LED pattern to PORTF LEDs
*pPORTFIO_TOGGLE = ucActive_LED;
/ ** /
现在我正在尝试修改代码以完成新功能,我希望它在按下按钮时从左到右闪烁,所以我的代码如下: / ** /
EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;
// shift old LED pattern by one, left to right
if(sLight_Move_Direction){
ucActive_LED == 0x0800;
ucActive_LED = ucActive_LED >> 1;
ucActive_LED == 0x0040;
}
// write new LED pattern to PORTF LEDs
*pPORTFIO_TOGGLE = ucActive_LED;
/ ** /
现在它无法工作或jus闪烁LED3,我该如何解决?
由于
答案 0 :(得分:0)
int Mode;
EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;
if(Mode == 1)
{
if((ucActive_LED = ucActive_LED >> 1) <= 0x0020)
ucActive_LED = 0x1000;
}
else if(Mode == 2)
{
if((ucActive_LED = ucActive_LED << 1) >= 0x1000)
ucActive_LED = 0x0020;
}
else if(Mode == 3)
{
if((ucActive_LED = ucActive_LED >> 2) <= 0x0020)
ucActive_LED = 0x1000;
}
// write new LED pattern to PORTF LEDs
*pPORTFIO = ucActive_LED;
}
然后将PORTFIO设置为按钮从PF2到PF5(SW13~SW10) 每个按钮对应于每个模式,因此我们可以看到模式1是LED从左到右闪烁。模式2从右向左闪烁。模式3使LED 2,4和6闪烁。