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.
Hello.
First of all, I want to say that I don't know if this is the right forum to do the question, but after days searching in the web, reading papers and changing the code, I'll try to explain my dude here.
I'm programming a device, with a USB communication in order to communicate with PC. I use an ATmega1281 with MAX3420 as USB controller. I get the windows recognize the device as COM Port...but I can only send or only receive data. If I try to set number of endpoints to 2 in the Data Class Interface descriptor, windows return an error (code 10), and can't initialize the device. Here I show the configuration descriptors I use. Thank you for your time in advance! and regards.
const unsigned char CD[]= // CONFIGURATION Descriptor { 0x09,// bLength 0x02,// bDescriptorType = Config 67,0x00,// wTotalLength(L/H) 0x02,// bNumInterfaces = 2 0x01,// bConfigValue 0x00,// iConfiguration 0xC0,// bmAttributes. b7=1 0x32,// MaxPower is 100 ma
// INTERFACE Descriptor 0x09,// length = 9 0x04,// type = IF 0x00,// InterFace Number = 0 0x00,// bAlternate Setting 0x01,// bNum Endpoints = 1 IN 0x02,// bInterfaceClass = 2 Communication 0x02,// bInterfaceSubClass = 2 0x01,// bInterfaceProtocol =1 (SubClass ACM,V.25ter) 0x00,// iInterface // Header Functional Descriptor (marks beginning of the concatenated set of Functional Descriptors) 0x05,// bFunctionLength, Descriptor size in bytes 0x24,// bDescriptorType, CS_INTERFACE 0x00,// bDescriptorSubtype, Header Functional Descriptor 0x10,0x01,// bcdCDC
// Abstract Control Management Functional Descriptor 0x04,// bDescriptorLength, Descriptor size in bytes 0x24,// bDescriptorType, CS_INTERFACE 0x02,// bDescriptorSubtype, ACM Functional Descriptor 0x06,// bmCapabilities
// Union Functional Descriptor 0x05,// bFunctionLength, Descriptor size in bytes 0x24,// bDescriptorType, CS_INTERFACE 0x06,// bDescriptorSubtype, Union Functional Descriptor 0x00,// bMasterInterface 0x01,// bSlaveInterface0
// Call Management Functional Descriptor 0x05,// bFunctionLength, Descriptor size in bytes 0x24,// bDescriptorType, CS_INTERFACE 0x01,// bDescriptorSubtype, Call Management Funct.Desc. 0x03,// bmCapabilities 0x01,// bDataInterface
// Endpoint Descriptor EP3-IN 0x07,// bLength 0x05,// bDescriptorType (Endpoint) 0x83,// bEndpointAddress (EP3 IN) 0x03,// bmAttributes (interrupt = 3) 0x40,0x00,// wMaxPacketSize 0x02,// bInterval, Maximum latency
// INTERFACE Descriptor 0x09,// length = 9 0x04,// type = IF 0x01,// InterFace Number = 1 0x00,// bAlternate Setting 0x01,// bNum Endpoints = 2 (IN&OUT) 0x0A,// bInterfaceClass = A (Data) 0x00,0x00,// bInterfaceSubClass, bInterfaceProtocol 0x00,// iInterface
// Endpoint Descriptor EP2-IN 0x07,// bLength 0x05,// bDescriptorType (Endpoint) 0x82,// bEndpointAddress (EP2-IN) 0x02,// bmAttributes (bulk = 2) 0x40,0x00,// wMaxPacketSize (64[0x40]) 0x00,// bInterval
// Endpoint Descriptor EP1-OUT 0x07,// bLength 0x05,// bDescriptorType (Endpoint) 0x01,// bEndpointAddress (EP1-OUT) 0x02,// bmAttributes (bulk = 2) 0x40,0x00, // wMaxPacketSize (64[0x40]) 0x00,// bInterval };
I check the frames with USb analyzer, and discover that were a problem with a configuration descriptor. Now I see that host don't ask me for a configuration descriptor of 160 Bytes, and it seems that there is no error in configuration descriptor. Anyway the behaviour of the device it's the same. Now, the frames I can see in the enumeration are:
1.Get Device Descriptor 128 6 0 1 0 0 64 0 Bus Reset 2.Set Address 0 5 1 0 0 0 000 0 3.Get Device Descriptor 128 6 0 1 0 0 018 0 4.Get Configuration Des. 128 6 0 1 0 0 255 0 5.Get String Descriptor 128 6 3 3 9 4 255 0 6.Get String Descriptor 128 6 0 3 0 0 255 0 7.Get String Descriptor 128 6 2 3 9 4 255 0 8.Get Device Qualifier 128 6 0 6 0 0 010 0 9.Get Device Descriptor 128 6 0 1 0 0 018 0 10.Get Configuration Des. 128 6 0 1 0 0 009 1 11.Get Line Coding 161 33 0 0 0 0 007 0 12.Set Control Line State 33 34 0 0 0 0 000 0
Frame Nº9 is Get Device Descriptor with length of 18, and the next Configuration descriptor with length of (109??). I thought this frame has a length of 19, and there was an error. Now I send all descriptors here and USB analyzer don't return an error. I don't understand why I only can send the first frame, and it don't works anymore...I see in the analyzer some frames OUT in EP 2, that is configured IN (and can't work as out), and is sent from host the following data:
1B DF 08 0A 00 00 00 0E 05 20 01 00 00 00 58 13 00 00 5F 29
These frames are not always identical, but are similar...
Regards.
After spending a long time changing the code, I always get the same result:
it seems that the device send the first frame by EP2 (IN Bulk) after connecting with serial port, the length and data sent is correct.
After this frame, the 'response' is that the frame is 4096 Bytes length.
The next operation device realices is to send a frame by EP3 (IN, Interrupt) (I don't know why, I don't try to send any frame by this EP, but the Serial State when the device connects to serial Port), but the status report tells me 'USBD_STATUS_BUFFER_OVERRRUN'.
Finally, there appears another try of sending a frame by EP2 (IN, Bulk), but the status says: 'USBD_STATUS_STALL_PID'.
I'm sure there are an error in the code, when I try to send the data by EP2, but I can't see it. I try to make a 'data toggle' in EP3 some times, and it works...for one time and no more (I suppose it was a set of circumstances, a simple coincidence), but it makes me think that I'm doing something wrong in the protocol sending data? (and the device is configurated correctly).
Well, finally the problem is solved!
There was an error, after sending set_control_line_status by interrupt EP, device don't send a ZLP correctly due a firmaware error, it was all...uff...I almost go crazy :P.
Thanks for your attention, speccially for Tsuneo.
Hi, i'm student in indonesia. i have a final project, i will develop some embedded system application that works with usb. after +-2 month i learning max3420, i still can't reply host OUT request. can you help me? can you send me your code?
thanks a lot
suriva (suriva.25 at gmail dot com)
I read your message, and I'll post the reply as soon as possible.
Regards, RubeÂ'n.
This is exactly the same issue i am facing. You mention that you reply to SET_CONTROL_LINE_STATE setup command from the host using the interrupt endpoint (which is 3 IN in your case). What is the exact reply you post to host? Is it NETWORK_CONNECTION status?
Also after you send the reply, you mention that a ZLP has to be sent. Is it from device to the host? Is it on control endpoint (EP 0 IN)?
I am looking forward to the reply from you or Tsuneo. Thanks in advance.