We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am working with a Cypress FX2 based board. There are 5 endpoints (BULK) that I use. Endpoint 1 and 4 are used for sending data from PC to FX2. Endpoint 2 and 6 are used to send data from FX2 to PC. Endpoint 8 is to be used for reset. Endpoint 1 is used for Initiating communication with the PC. The firmware is polling for the a flag which is set by the ISR for this endpoint e.g. Polling function: void poll_func(void) { if( EP1_Enabled) { resetFlag = 0; //clear the reset process_command(); EP1OUTBC = 0 ; // re-arm endpoint 1 OUT SYNCDELAY; EP1_Enabled = 0; } } ISR: void ISR_Ep1out(void) interrupt 0 { // tell polling software we have new data EP1_Enabled = 1; EZUSB_IRQ_CLEAR(); EPIRQ = bmEP1OUTIER; } The process_command() processes user requests and reads some data (with timeouts) of FPGA and fills up output endpoint 82Hnd arms it as below: { /* Fill 32 bytes in ep2 buffer Maximun time allowed = 50 millsec. */ receive_wait(32, 50); EP2BCH = 0; // arm endpoint 2 IN EP2BCL = 0x20; /* if both buffers are still committed to USB, wait around until one of them is free */ while((EP2CS & bmEPFULL) && !resetFlag ) ; } The ISRs for EP2 and EP6 are empty. i.e. void ISR_Ep2inout(void) interrupt 0 { } The ISR for EP8 used for reset is as below: void ISR_Ep8inout(void) interrupt 0 { EP8BCL = 0x80; //re-arm endpoint 8 SYNCDELAY; resetFlag = 1; EZUSB_IRQ_CLEAR(); EPIRQ = bmEP8IER; } The PC sends data on EP1 and then starts waiting to get data back on EP2. In some conditions, I want to use receive_nowait() instead of receive_wait() i.e. I want to do receive_nowait(32); so that this call would become a blocking call and firmware control would come out of this function only after 32 bytes are received or if the resetFlag is set to 1. The PC application spawns a thread and sends data on EP1 and then it waits on data from EP2 (since receive_nowait() is blocking. Now if I have to set the resetFlag, I send data on EP8, which should work. But it gets queued, till I come out of receive_nowait() and arm EP2. Only after this, I see that resetFlag is getting set to 1. I seems like interrupts get disabled, while I am handling any other interrupt.I tried setting EA(IE Register bit 7) to 1, EUSB (EIE Register Bit 0) to 1 and USBINT (EXIF register bit 4) to 1 How do I fix this? Any ideas would be greatly appreciated. Thanks Dave
Any suggestions? Thanks