Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USB enumeration problem

Status
Not open for further replies.

bunalmis

Full Member level 5
Full Member level 5
Joined
Jan 3, 2003
Messages
281
Helped
19
Reputation
38
Reaction score
13
Trophy points
1,298
Location
Turkey
Activity points
2,208
I am trying to write usb enumeration routines. My program has errors. But where I don't know.

1) PC, the command sends GetDeviceDescriptor. (80 06 00 01 00 00 40 00) Hex
- The software sends DeviceDesriptor.
2) The reset signal coming from the PC
3) PC sends the command SetAddress (00 05 02 00 00 00 00 00)
- I read and I set the address. (Address is 2)

These processes take place two more times.

And PC gives an error message "USB Device Not Recognized"

My DeviceDescriptor data {18, 0x01, 0x10, 0x01, 0xFF, 0xFF,0xFF, 0x08, 0x47, 0x05, 0x31, 0x21, 0x21, 0x00, 0x01, 0x02, 0x03,0x01}

How can I find the problem?

My DeviceDescriptor can go wrong in PC

How can I check it?
 

I want to know observing the bytes of datas in the transmitted and received packet.

What computer programs do you recommend to me?
 

My usb device receive following setup command.

This is may be Get Descriptor by first byte is 0x81 and i dont know.

What is it?

81 06 00 22 00 00 5D 00.."..].
Recipient: Interface
Request Type: Standard
Direction: Device->Host
Request: 0x6 (GET_DESCRIPTOR)
Value: 0x2200
Index: 0x0
Length: 0x5d
 

Nobody help to me but i found my mistakes.

USB enumeration problem
I am trying to write usb enumeration routines. My program has errors. But where I don't know.

1) PC, the command sends GetDeviceDescriptor. (80 06 00 01 00 00 40 00) Hex
- The software sends DeviceDesriptor.
2) The reset signal coming from the PC
3) PC sends the command SetAddress (00 05 02 00 00 00 00 00)
- I read and I set the address. (Address is 2)

These processes take place two more times.

And PC gives an error message "USB Device Not Recognized"

My DeviceDescriptor data {18, 0x01, 0x10, 0x01, 0xFF, 0xFF,0xFF, 0x08, 0x47, 0x05, 0x31, 0x21, 0x21, 0x00, 0x01, 0x02, 0x03,0x01}

How can I find the problem?

My DeviceDescriptor can go wrong in PC

How can I check it?

After i received the address, I set this address immediately and i send ACK using this new address. Problem this.

Because i must send the ACK using old (0) address. After i must set the new address.

PC wait ACK from old address zero, not wait ACK from the new address.

Re: USB enumeration problem
My usb device receive following setup command.

This is may be Get Descriptor by first byte is 0x81 and i dont know.

What is it?

81 06 00 22 00 00 5D 00.."..].
Recipient: Interface
Request Type: Standard
Direction: Device->Host
Request: 0x6 (GET_DESCRIPTOR)
Value: 0x2200
Index: 0x0
Length: 0x5d

81 06 00 22 00 00 5D 00 this is Get HID Report Descriptor command.

You can find more details at the Human Interface Device Class Decoder - HID Descriptor, HID Report, HID Request Visualizer
 
Last edited:
Hi.

Hope you can clear my doubt in USB enumeration problem. I am using PIC24FJ256DA206 microcontroller as Host and USB mouse as Device. After successfully reading Device Descriptor from usb mouse, i establish Set_Address command what you have mentioned above. I even could get acknowledgement from Device side. After this step, i perform a simple IN transaction(No Data Stage) as Status Stage. I can get ACK for this Status stage also.

Then, i update my U1ADDR register of host with new address what i set for Mouse. Then, i transmit my Get_Configuration command which end up with Time Out Flag set.

This is the Get_Configuration command i send to USB mouse.

volatile unsigned char Get_Config[]={0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x00};

Please help me to over come this problem.
 

Hi.

Hope you can clear my doubt in USB enumeration problem. I am using PIC24FJ256DA206 microcontroller as Host and USB mouse as Device. After successfully reading Device Descriptor from usb mouse, i establish Set_Address command what you have mentioned above. I even could get acknowledgement from Device side. After this step, i perform a simple IN transaction(No Data Stage) as Status Stage. I can get ACK for this Status stage also.

Then, i update my U1ADDR register of host with new address what i set for Mouse. Then, i transmit my Get_Configuration command which end up with Time Out Flag set.

This is the Get_Configuration command i send to USB mouse.

volatile unsigned char Get_Config[]={0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x00};

Please help me to over come this problem.

Hi,
I'm working on USB in host mode, when i'm writing the packet in to the Tx FIFO for the device descriptor, channel is immediately disabled and Channel transaction error is raising, why it is happening like this? I don't understand.

Can any one please explain about this.

Thanks & Regards,
Chandu.Kurapati.
 

Hi Mr chandru.kurapati,

I am not aware of the problem you are facing right now, but I hope my ideas may help you rectify your problem.
1. Are you sending the correct 8-byte setup packet to retrieve the 18-byte Device descriptor from the usb device?
2. To which end point are you sending this setup packet? I hope you are sending it to CONTROL IN end point of the device.

If you are using a micro controller,
3. Have you turned on the V bus? You can check it by sensing a +5V in Vbus line.
4. Have you initialized the Buffer descriptor table, if needed any? I used PIC24F series in which i need to initialized the Buffer descriptor table in a 512 byte aligned RAM memory.
5. Have you enabled all the required parameters in USB control registers?
6. Have you checked whether you are getting 1ms timer interrupt set by the USB serial interface engine?

I hope you will provide more details about processor/controller you are using, the usb version you are using(i use USB 2.0).
 
Hi Mr gopintj,
I'm using STM32F407 micro controller and USB2.0 version,

1. I'm sending the correct 8 bytes setup packet for the device descriptor, they are(80 06 00 01 00 00 40 00) Hex

2. your second point also i'm following.

3. I' using the NONVBUSSENSE option for the VBUS, feature is hardware all ways considered VBUS is 5V.

4. I don't understand your 4th point, please explain it in more detail.

5.I hope all the required parameters are enabled.

6. I'm not checked that 1ms interrupt , please explain me how to check that interrupt.

and i didn't have any idea to check the VBUS, please explain me how to check that VBUS voltage level.

Thanks & Regards,
Chandu.Kurapati.
 

Hi Chandru,

Buffer descriptor table is for PIC micro controllers. Buffer descriptor table is the one which contains registers for 16 endpoints supported by PIC24F micro controller. This registers transfer the access of FIFO Buffers between USB serial interface engine and the user. Along with this, it provides status information about previous usb transaction.

I would suggest you to send this data packet ->0x80 0x06 0x00 0x01 0x00 0x00 0x08 0x00 rather than sending 80 06 00 01 00 00 40 00. According to USB 2.0 specification, for a setup packet, the wLength must me the maximum size of the descriptor that one is going to retrieve. But, In your case, this is the first descriptor you are going to receive after attaching your device to the host development board. In this time, you are not aware of the maximum buffer size that the device's control IN and OUT endpoints support. So, you need to request only the first 8 bytes of the device descriptor from the device. From the received 8-byte data packet, you will come to know the max packet size of the CONTROL IN and CONTROL OUT end points. With this information, this time, you can send the same setup packet with updated wLength value.

For example, the maximum buffer size of USB mouse's control end points is of only 8 bytes. In order to retrieve the mouse's 18-byte device descriptor, you need to send three consecutive IN packets to get the full device descriptor.

In case of android phones, max buffer size of their control end points is 64 bytes. To get its device descriptor, one need to send only one setup packet followed by only one IN packet.

I am not aware of the usb device you are using. So, i suggest you to send this setup packet ->0x80 0x06 0x00 0x01 0x00 0x00 0x08 0x00. Let me know what you get in return after sending this packet.

For reference, Have you got an Attach interrupt after plugging your usb device?
 

Hi gopintj,
In this STM controller also we have to configure the RAM address and size to access the FIFO's, I'm already configured that one.

And that next thing is USB mouse is the low speed device, it's buffer size only 8 bytes but i'm running MSC application i.e pen drive it is a full speed device that's why i'm transmitting wlength as a 64 bytes.

i have a flexibility to run HID application also, i will run that application and update you soon.

Request: My name is Chandu please observe this

Thanks & Regards,
Chandu.Kurapati.

- - - Updated - - -

Hi gopintj,
Can you please explain me how we know our controller full speed host runs at the 48 MHZ frequency, there is any testing procedure for it.
Thanks & Regards,
Chandu.Kurapati.
 

Hi gopintj,
Can you please explain me about how to test SOF pulse on the GPIO pin,

My testing process is:
1. I'm configure the GPIO pin what they mention in the datasheet.
2. configure the mentioned timer here TIM2 in capture mode with 1khz for 1 ms frame period for FS & configured the mentioned OTG FS SOF bit in the timer registers.
3.Enabled the SOFOUT bit.
and then I'm observing the SOF signal for at the mentioned GPIO, but nothing is showing i don't understand the problem.

can you please explain about it if you are aware of this issue.

Thanks & Regards,
Chandu.Kurapati.
 

1. I'm configure the GPIO pin what they mention in the datasheet.
2. configure the mentioned timer here TIM2 in capture mode with 1khz for 1 ms frame period for FS & configured the mentioned OTG FS SOF bit in the timer registers.
3.Enabled the SOFOUT bit.
and then I'm observing the SOF signal for at the mentioned GPIO, but nothing is showing i don't understand the problem.

I need to tell you that the procedures to create 1ms SOF in USB communication differs for different micro controllers.

I follow the below procedure to create 1ms SOF signals in PIC micro controllers.

1. At first, I initialize the USB serial interface engine by configuring the necessary registers.
2. I enable USB attach/detach interrupts, 1ms SOF interrupt, successful Packet transaction and various error interrupts.

These setups let me do proper USB operations. I request you to try any working USB firmware so that you can confirm that the problem relies only on your source code.

Just tell me whether your source can enter into USB ISR when a USB device is connected to the board?
 

Hi gopintj,
yesterday i was tested the SOF interrupts for every 1 ms it's working fine, and ISR for connection, disconnection and SOF interrupts are invoked no problem with that.

when ever i transmitted the setup packet into the Tx FIFO, channel is disabled automatically and transaction error interrupt is invoking, I'm following the STM32F cube version 1.0, i was checked the all interrupts for that one in the keil compiler that is worked fine.

I want to change that build into the my format using coocox coIDE this problem is occuring, i don't understand is it compiler problem or any thing else.

Thanks & Regards,
Chandu.Kurapati.
 

Hi gopintj,
Today I tested the Mouse instead of the pen drive, it's successfully transmitted the SETUP packet and invoked the ACK & transaction completed interrupt, now I'm planning to read the device descriptor.

Thanks for your valuable suggestions.

Thanks & Regards,
Chandu.Kurapati.
 

Hi gopintj,
Today i successfully read the device descriptor of the Mouse(low speed device), but with the full speed device(pen drive)same TxERR problem is repeated, but for my project i want to work it on any full speed device.

Do you have any idea about it, please suggest any ideas about it.

Thanks & Regards,
Chandu.Kurapati.
 

Hi chandu,

I remember I too faced the same problem while shifting from writing firmware for low speed device to high speed device. Then, I got a ready made USB stack from microchip's application library. With that, I communicated with android phones.
What I can suggest you at this moment is to use a ready made USB stack for your controller. This was what experts suggested me while I approached this forum. :)

Regards,
N Gopi.
 

Hi Gopi,

I am happy to inform you enumeration for the Low speed devices(mouse,keyboard etc...)are completed successfully, now i want to write application for them. please share any example code for the key board or mouse application.

Now on words i want to work on full speed devices, i will inform you further information.

Thanks & Regards,
Chandu.Kurapati.
 

Hi Chandu,

I am happy to hear that you have successfully done enumeration for low speed devices. In order to write your own applications to grap USB mouse and Keyboard, need to study HID device classes at first.

https://www.microchip.com/forums/m730375.aspx

The above link will direct you to microchip's user forum where I uploaded a file which i used to interact with usb keyboards. The code which I posted there was not written in any standard and I have forgotten its flow of execution. So, read the two datasheets which I mentioned in that forum and write an application by your own.

Regards,
N Gopi.
 

Hi chandu,

This is the one more step i followed to communicate with full speed devices. As soon as I detect a J state (differential 1) while connecting the device, I clear a flag bit in one of the USB control registers to inform the Serial Interface Engine(SIE) that the connected is a full speed device.

If i find a differential 0 while connecting a device, I set the same particular bit in the usb control register. So that the SIE will do proper data transaction with adequate clock speed.

The flag bit which i set is in U1ADDR register which holds the device address. Hope this will help you fix your problem.

Regards,
N Gopi.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top