Hi!
First of all, some information: I'm starting a project using LPC2388 (I have MCB2000 board) and I'm new to ARM. In this project we have some code provided by other company to speed up our development, a kind of library to access some functions like USB, UART, SPI, etc. The code we have for USB is based on Keil's USBCDC, and it is ported to work with FreeRTOS. We have to use CDC because this project is supposed to act as a Modbus Slave and should be compatible with the softwares we have (using a USB-Serial converter is not desirable). For testing purposes, we are echoing all data receive by USB, and it works fine, apparently we have no data loss. I use teraterm and I don't send more than 256 bytes at a time.
Now my question: I noticed that in the descriptor they have defined the max size of the bulk endpoints in 256 bytes. As far as I know, the max size of a bulk endpoint (for a full-speed device) is 64 bytes, but please correct me if I'm wrong. So, I don't understand how it is working! I tried to simply change the max size in the descriptor, but then I have data loss. This is probably happening because the code provided doesn't handle ZLP and it's not dividing data in 64 (or whatever is the proper max size) bytes packets. I also tried to use a USB sniffer (software - I have Snoopy and USBlyzer) but I got more confused. I always see the host sending up to 100 bytes packets, no matter the max size defined (64 or 256 bytes).
Thanks in advance! Regards Elisandra
"but never succeeded in reading FE bit status"
I mistakenly use WrCmd() in the posts. http://www.keil.com/forum/docs/thread13504.asp It is replaced to RdCmdDat() as follows.
a) bulk OUT EP - Check the FE bit of "Select Endpoint" command, if the EP buffer is empty, return - - WrCmd( CMD_SEL_EP(EPAdr(CDC_DEP_OUT)) ); if ( CMD_DATA & EP_SEL_F == 0 ) return; // - wrong
if ( RdCmdDat( CMD_SEL_EP(EPAdr(CDC_DEP_OUT)) ) & EP_SEL_F == 0 ) return;
b) bulk IN EP - Check the FE bit of "Select Endpoint" command, if no empty EP buffer, return - - WrCmd( CMD_SEL_EP(EPAdr(EPNum)) ); if ( CMD_DATA & EP_SEL_F != 0 ) return; // - wrong
if ( RdCmdDat( CMD_SEL_EP(EPAdr(CDC_DEP_IN)) ) & EP_SEL_F != 0 ) return;
Tsuneo
Hi,
Thank you, Tsuneo! It's really nice of you sharing your knowledge :) I find it very difficult to get used to LPC family... I understood the steps you've explained, but I was unable to implement them by myself (I didn't know which macros/functions/definitions to use, there isn't many explanaitions on the code...). Also I find it almost impossible to understand the datasheet. Just one detail, I got it working this way: if ( RdCmdDat( DAT_SEL_EP(EPAdr(CDC_DEP_IN)) ) & EP_SEL_F != 0 ) return;
Now, thanks to Tsuneo, I got it all working :)
Regards, Elisandra