USB status LED not functioning well

Status
Not open for further replies.

nsw1216

Member level 3
Joined
May 7, 2010
Messages
60
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,667
I am creating a firmware for PIC18F4550 with the function of BlinkUSBStatus inside. But when i toggle one of my other LEDs from on to off or vice versa, the blinking LED stops blinking. I am wondering why it will stops blinking.

Actually the purpose of the blinking LED is to indicate the data transferring between the USB device and the PC. But once i toggle my LEDs, it stops blinking.

Anyone have any ideas towards this problem ?
Your replies are most welcome and appreciated.

Below is the code for the BlinkUSBStatus function.
Code:
void BlinkUSBStatus(void)
{
    static WORD led_count=0;
    
    if(led_count == 0)led_count = 10000U;
    led_count--;

    if(USBSuspendControl == 1)
    {
        if(led_count==0)
        {
            mLED_3_Toggle();

        }//end if
    }
    else
    {
        if(USBDeviceState == DETACHED_STATE)
        {
            mLED_3_Off()
        }
        else if(USBDeviceState == ATTACHED_STATE)
        {
            mLED_3_On()
        }
        else if(USBDeviceState == POWERED_STATE)
        {
            mLED_3_On()
        }
        else if(USBDeviceState == DEFAULT_STATE)
        {
            mLED_3_On()
        }
        else if(USBDeviceState == ADDRESS_STATE)
        {
            if(led_count == 0)
            {
                mLED_3_Toggle();
                
            }//end if
        }
        else if(USBDeviceState == CONFIGURED_STATE)
        {
            if(led_count==0)
            {
                mLED_3_Toggle();
                
            }//end if
        }
    }

}

Thank you.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…