blackfin bf537 LED blinking

275 Views Asked by At

These codes below are the example of LED blinking program for blackfin bf537 the LEDs will blink from right to left and the toggle back. /**/

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;  

/**/

Now I am trying to modify codes to accomplish the new function, I want it blink from left to right one time when i push the buttom, so there are my codes below: /**/

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; 

/**/

Now it can't work or jus blink LED3, How can I fix it?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

after few days thinking, here is my answer:

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;  
    }

and then set the PORTFIO to push buttons from PF2 to PF5(SW13~SW10) each button correspond to each mode, therefore we can see that the mode 1 is LEDs are blinking from left to right. Mode 2 is blinking from right to left. And Mode 3 is blinking the LED 2, 4, and 6.