Setup for K81's USB Interface in MCUXpresso

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

Setup for K81's USB Interface in MCUXpresso

Jump to solution
1,010 Views
halsteger
Contributor II

Clocking USB Interface:

(I also opened an NXP support case - # 00310003 - for this question.)

I'm trying to setup a Kinetis K81 (MK81FN256VDC15) in a "crystal-less" mode; i.e. to use the K81's internal 48MHz oscillator to be the source clock for all of the IC's clocking (no crystal on EXTAL0/XTAL0 pins). I can do most of this setup in MCUXpresso's Clock Config Tool. But for the IC's USB interface, I can't find how to access the USB interface related registers to set IRC_EN and CLOCK_RECOVER_EN which apparently is required to use this 48MHz internal clock as the USB FS clock. I don't see any USB support under the Peripherals Config Tool.

I'm using MCUXpressoIDE 11.2.0_4120 and SDK_2.5_TWR-K81F150M.zip. I'm targeting a K81 on a board of my own design but using the SDK for the TWR-K81 as a starting point.

Powering the K81’s USB Interface using system power

In addition to setting up the clocking, I have a question about powering the K81’s USB interface.  The examples in the K81 datasheet and the demo/eval boards use bus-power to provide power to the K81’s VREGIN pin so show how to hookup VREGIN and VOUT33 to VBUS for that case.  My design is system-powered and the datasheet doesn’t explicitly provide guidance for that case. I’ve hooked up the VREGIN and VOUT33 pins to GND through 10Kohm resistor.  Is this correct or do I need to hookup VREGIN to my board’s 3.3V power supply (the supply powering the K81’s VBAT, VDD1-3, VDDA, and VDDIO_E pins) and add bypass caps on VREGIN and VOUT33?

 

Labels (1)
0 Kudos
Reply
1 Solution
952 Views
halsteger
Contributor II

Hi Mark,

Thanks again for your help with this issue.

Regarding the clocking issue, I was able to make some code modifications in addition to change some setting using the Clock Config Tool.  While I still don't understand why the USB interface doesn't appear as a peripheral under Peripherals Config Tool, I did get the design working.

 

Regarding the USB Power and REGIN/VOUT33, I've hooked a 3V3 supply rail on the board up to REGIN and added some bypass caps on REGIN and VOUT33.  The interface is working properly.

 

Thanks again,

Hal 

View solution in original post

0 Kudos
Reply
4 Replies
1,004 Views
mjbcswitzerland
Specialist V

Hi

You can use the FRDM-K82F board as HW reference for connecting the VREGIN to a local power supply. The internal regulator is a linear one at about 0.6V drop-out and passes through when the input voltage is less than about 3.6V. Normally it is used with 5V input to have 3.3..3.6V output but will accept inputs down to 2.7V, with 2.1V output. It is worth checking that the USB transceivers still work well at low levels but 3V3 input is foreseen for such operation too.
Pulling the input/output to GND will disable the regulator to save power but will not allow the USB interface to operate since its transceiver will be disabled too.

The uTasker project also supports your device and USB in case you would like to look at an alternative solution which allows simulating the chip and the USB peripheral operation, as well as crystal-less USB mode. Applications are then automatically compatible with faster i.MX RT devices in case a switch is required later without extra firmware redevelopment effort, or benefit from lower price/better performance - eg.600MHz i.MX RT 1020 with 2 HS USB costs $2.30 against the K80 with single FS USB at $4.35. The uTasker K8x loader also gives secure, fail-safe field updating for applications from any source.

You probably are fully aware already but only use device mode of operation (not host) is possible without a crystal source.
In any case, the code that you seem to be missing is the following:

SIM_SOPT2 |= (SIM_SOPT2_USBSRC | SIM_SOPT2_PLLFLLSEL_IRC48M); // set the source to IRC48M
SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV_1; // no divide when IRC48M is used

USB_CLK_RECOVER_IRC_EN = USB_CLK_RECOVER_IRC_EN_IRC_EN; // enable 48MHz IRC clock and clock recovery
USB_CLK_RECOVER_CTRL = USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN;

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training or product development requirements

https://www.utasker.com/kinetis/FRDM-K82F.html
https://www.utasker.com/kinetis/TWR-K80F150M.html
https://www.utasker.com/iMX/RT1020.html

 

0 Kudos
Reply
996 Views
halsteger
Contributor II

Hi Mark,

I appreciate your quick and detailed reply.

Regarding the K81's USB power supply, it's looking like I need to supply power to VREGIN and add some bypass caps to GND on VREGIN and VOUT33. Thanks.

Regarding selecting the K81's internal 48KHz clock as the USB FS clock, I'm aware of the settings you describe but I can't find where in MCUXpresso I can make those register settings.  As I wrote, I can do most of the clock settings/selections using MCUXpresso's Clock Config Tool. But I can't find where I can set IRC_EN and CLOCK_RECOVER_EN. The USB interface doesn't appear in the Peripherals Config Tool (or any of the other Config Tools for that matter).

Hal

0 Kudos
Reply
993 Views
mjbcswitzerland
Specialist V

Hi Hal

I don't use the config tools so I don't know what they support and what is missing.

Maybe you could add the missing configuration manually?

Regards

Mark

0 Kudos
Reply
953 Views
halsteger
Contributor II

Hi Mark,

Thanks again for your help with this issue.

Regarding the clocking issue, I was able to make some code modifications in addition to change some setting using the Clock Config Tool.  While I still don't understand why the USB interface doesn't appear as a peripheral under Peripherals Config Tool, I did get the design working.

 

Regarding the USB Power and REGIN/VOUT33, I've hooked a 3V3 supply rail on the board up to REGIN and added some bypass caps on REGIN and VOUT33.  The interface is working properly.

 

Thanks again,

Hal 

0 Kudos
Reply