USB VBUS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB VBUS

1,910 Views
a8Chcx
Contributor V

Hi,

I am using K66F MCU to build USB HID to communicate with PC. And I have the problem:

1) When I provide VBUS by PC host, it works fine when USB cable is plugged in. But, if USB not plugged in, the firmware is hang up. 

2) If I plugged in  USB cable, start running, then I can plug or unplug without any problem.

3) If I power USB by 5VDC, not from VBUS, it works fine...

Can anyone help me to debug where the problem is and how to fix it?

Thanks,

Christie

 

0 Kudos
Reply
10 Replies

1,892 Views
a8Chcx
Contributor V

Hi,

I found the following cause the problem:

The MCU is stalling after command execution

static void USB_DeviceEhciSetDefaultState(usb_device_ehci_state_struct_t *ehciState){

...

hciState->registerBase->DEVICEADDR = 0U;

}

Can anyone help me how to fix the problem?

Thanks,

Christie

0 Kudos
Reply

1,886 Views
bobpaddock
Senior Contributor III

Setting the USB Address to Zero at the start of enumeration is normal. That in itself isn't going to cause any issues.

What is the line before that doing?  Sometimes the debuggers can be off by a line when there is a fault.

What is powering the device when this happens?

Is there a bus fault trap set up that would show the address of any bus faults? Could something be invalid with ehciState in this power configuration?

 

0 Kudos
Reply

1,883 Views
a8Chcx
Contributor V

Another thing, it works fine if I remove set address command...

0 Kudos
Reply

1,878 Views
bobpaddock
Senior Contributor III
That could cause odd issues with enumeration if the device is moved to another USB port or hub while it remains powered.
0 Kudos
Reply

1,884 Views
a8Chcx
Contributor V

Hi bobpaddock, 

Thanks.

If VREG_IN0, VREG_IN1, and USB1_VBUS of MCU are powered by 5V or Vbus(USB cable plugged in), it works fine.

If there is no power on VREG_IN0, VREG_IN1, and USB1_VBUS of MCU, it hangs on set address command. But, if I plug in USN cable, then it works again...

If there is any privilege to write this register(offset=0x0154)? Or need to enable something before writing to this register?

Thanks,

Christie

0 Kudos
Reply

1,880 Views
bobpaddock
Senior Contributor III
So there is no power to the USB module then (Being independent of the chips power)? No way to tell what an unpowered module will do.

I don't know that chip specification to answer your other question. The general answer of Kienits line is 'no'.

0 Kudos
Reply

1,842 Views
a8Chcx
Contributor V

Hi bobpadock,

 

Yes. You are right. If there is power on VEG_IN0&1, it works fine.

I am using BUS_powered mode. If there is no power and should not initialize USB?

I have to know the USB1_VBUS pin status. Could you tell how to do that?

I am using usb_1.6.3 for K66F MCU for now?

Thanks,

Christie

0 Kudos
Reply

1,838 Views
a8Chcx
Contributor V

Hi,

My problem is:

In bus-power mode USB device, if no USB cable connected to Host, there is no power and I am hanging on set to the default address line. But, if no power, USB drive is not normal, I can't read the USB1_VBUS register, right?

Can anybody tell me how to get USB1_VBUS status? Can I read this register even without USB power?

I am using K66F MCU...

Thanks,

Christie

0 Kudos
Reply

1,829 Views
bobpaddock
Senior Contributor III
The solution that has been recommended by NXP here in the past is a voltage divider to an I/O pin for VUSB detection.

0 Kudos
Reply

1,827 Views
a8Chcx
Contributor V

Hi bobpaddock,

Thanks.

Do you have any detail for this recommendation?

 

0 Kudos
Reply