AnsweredAssumed Answered

TWR-K20D72M USB Micro as device not working

Question asked by Marc Bunyard on Jun 5, 2013
Latest reply on Jul 3, 2013 by Marc Bunyard

I'm using Code Warrior 10.4 with Processor Expert on the TWR-K20D72M, trying to get the USB OTG on the TWR-K2072M board to function as a device, and am having little success.  The reset from the Host is detected, then nothing.


Jumpers 5-6 are shorted along with J2 and J20.

I'm using the MQXLite component.

I'm trying to use the USB_LDD component:

Input clock frequency: 48 MHz.

Interrupt Service/Event: Enabled.


Tranceiver Type->Device Data Rate: Full Speed

DP Pullup: Enabled

VBUS Pins->VBUS detect: Enabled

EP0->Control transfer-> Max Packet Size: 64

Auto initalization: No.


In my initialization task I'm making the following calls:



USBDevData = USB1_Init(0);          // I have questions about the 0 parameter (UsrDataPtr), but it hasn't seem to come into play yet.

                                                         // I also hacked this code.  See below.



digENUSB();                    // Actually sets PTC9 low to disable power to VBUS

digUSBMiniA();                // Set PTC10 high.  B Device ID ???





After this initialization, I see something a little questionable:

USB0_ADDINFO = 0x01                         ; Indicates that we are in host mode

USB0_CTL = 0xC1                                  ; HOSTMODEEN = 0 ???  Host mode should be disabled.

In the description of the Method USB_Init, there is the statement "This method doesn't enable device pull-up. Use Enable() method to enable device pull-up".  Yet in the code in USB_Init, there is the line: DevDataPtr->EnUser = TRUE;

And in the opening line of code in USB_Enable there is the line: if(!DevDataPtr->EnUser){ <Body of the method>}. The call to USB_Init negates any action in the call to USB_Enable.  I commented out the line in USB_Init so that I could see what works.  Now, when I attach a USB Host, my hardware detects the reset, executes the code for a USB reset in the function USB_DeviceIsr, then nothing.

I'm not sure I'm using this component correctly.  With the other features on the chip, there were components listed under CPU internal peripherals.  Not so with USB. ???