1 Reply Latest reply on Feb 18, 2011 12:54 AM by udayanu_

    USB interrupt

      I am very new to programming microcontrollers so if I am asking a dumb question, sorry. I downloaded the "USB Interrupt Loopback Example" but it has a while loop in the beginning of main c that is preventing me from implementing the rest of my program. I need it to operate similar to your "nesting interrupts example". Is there a way to keep the loop out of main c, or a way to ignore it until the usb cable is plugged into the board? I have been working with c programming and Psoc less than 3 months so any help would be appreciated. Thanks.

        • 1. Re: USB interrupt



          It's a very valid question that you have asked. The USB Example projects on the web are projects dedicated to demonstarte the USB capability. Hence there is a while loop which is not exited untill USB enumeration is complete.


          Once your USB device(any USB chip, here it is PSoC) is inserted, the host(PC or similar device) assigns a configuration to the USB device. The API USBFS_bGetConfiguration ( ), checks if a valid configuration has been assigned. Hence as you pointed out, PSoC device will stay in the while loop, while( ! USBFS_bGetConfiguration ( ) ), untill PSoC device enumerates as a USB device and gets a valid device configuration.


          However in general application this is not necessary, you can develop your custom project code and add a condition that checks to see if a valid configuration has been assigned  "if( USBFS_bGetConfiguration ( ) )". You can set a flag once the USB device has got valid configuration an then start all your USB transactions.


          Feel free to ask any questions. Everybody has to go through the learning curve, we are there to help you !