|
![]() USB
![]() BulkEP1_IN problem
|
| next newest topic | next oldest topic |
| Author | Topic: BulkEP1_IN problem |
|
joshmorong New Member |
Put in a ticket with Silabs, but in mean time, perhaps someone will have insight here. --The C8051F341 has EP0 including vendor commands, EP1 for bulk IN transfers, and EP2 for bulk OUT transfers. The USB-ISR reads CMINT, IN1INT, and OUT1INT, storing them in local variables, then decodes, starting with EP0, then EP1, then EP2. The EP1 function call within the USB-ISR sets a flag when an interrupt is received, then polls for the flag to be cleared by the high-priority T2 interrupt after it moves data from SRAM. The USB-ISR, then polls IPRDY again to see if alternate FIFO (double buffering) is open and resets flag and waits. This works, but I have found that when I slow my EP1-IN data rate (asking for less data), the device is left waiting for 64 bytes of data to be ready to transmit, and thus the USB-ISR is stuck waiting for that flag. Effectively, I miss EP0 vendor commands, which occur after I have entered the USB-ISR and read it--in which case they would have been handled before the EP1 function call, but before exiting the EP1 portion of the USB-ISR. Does this mean that IN1INT can only be set while the device is not in the USB ISR? I tried moving the arming of IPRDY and checking for 2nd FIFO open our of USB-ISR, so that the device did not sit in the ISR waiting for data to come in on T2 interrupt. This removed the issue, but introduced an issue where packets were sent prematurely (I believe) exhibiting channel skipping on my software for odd channel counts since at 2-bytes per sample, even channel counts never span consecutive bulk packets. (64/6 bytes per sample set, 3 channels enabled, means 10 consecutive samples fit into packet number n, with 2 of 3 channels stuffed into last 4 bytes)... Thanks for reading, and for any suggestions. IP: Logged |
|
Tsuneo Member |
> The EP1 function call within the USB-ISR sets a flag when an interrupt is received, It's fine, but, > then polls for the flag to be cleared by the high-priority T2 interrupt after it moves data from SRAM. Don't wait for T2 interrupt in the USB-ISR. EP1 handler in the USB-ISR finishes just by setting the flag. You need to implement another process, which polls both of EP1 and T2 flags in main loop. This process fills EP1 FIFO when both flags are asserted. Disable USB interrupt while this process is filling EP1 FIFO, to ensure exclusive access of the USB engine. Tsuneo IP: Logged |
|
joshmorong New Member |
Hi Tsuneo, Thanks for your help! Timely as I still have not heard from MCU Apps. I have things working now, with EP1 data loaded from SRAM to the USB FIFO in the Main loop. I'm still unclear on effect of double buffering, as the F341 data sheet (16.12.1.Endpoints1-3 IN Interrupt or Bulk Mode, page 181) states: Since the EP1 portion of the USB_ISR is setting my flag allowing the USB FIFO to be filled, does this mean I have effectively disabled double buffering? On another note, I was quite surprised to see that the MOVX command can apparently be interrupted before the command has completed. I had noticed when I changed code that much of my data was corrupted. If I disable T2 interrupt around my Main Loop MOVX command CLR ET2 the issue is cured... I perform context save and return on both the accumulator, and the data pointer in my T2 interrupt, so this seems wrong. My take is that the MOVX command which now requires adjustable timing registers allowing interface with slower SRAM, may not have been fully tested, when configured that way, and that it may allow an interrupt to occur after the minimum number of SCLKs that MOVX may be configured for--any thoughts? Thanks, IP: Logged |
|
Tsuneo Member |
> Since the EP1 portion of the USB_ISR is setting my flag allowing the USB FIFO to be filled, does this mean I have effectively disabled double buffering? To use double buffer effectively, the firmware polls INPRDY bit of IN EP1, instead of the flag set by USB_ISR for EP1. When INPRDY bit is 0, the FIFO accepts another packet.
It's the first time I heard that off-chip MOVX is disturbed by interrupt. Tsuneo [This message has been edited by Tsuneo (edited August 03, 2010).] IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() |
|
Have you seen our MCU Knowledge Base?