代码之家  ›  专栏  ›  技术社区  ›  Harvey Chang

blackfin bf537 LED闪烁

  •  0
  • Harvey Chang  · 技术社区  · 8 年前

    以下代码是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; 
    

    /**/

    现在它无法工作或无法正常工作,我如何修复它?

    谢谢

    1 回复  |  直到 8 年前
        1
  •  0
  •   Harvey Chang    8 年前

    经过几天的思考,我的答案是:

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

    推荐文章