Can the L26Z with 32Khz Xtal generate a clock for USB MSB Device

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

Can the L26Z with 32Khz Xtal generate a clock for USB MSB Device

Jump to solution
2,550 Views
neilhancock
Contributor IV

Hi, I'm using the KL26Z with an external 32Khz crystal for time keeping, which can generate

I'm trying to set up the USB to be a device - kboot - following some of the examples, and the first setup is the clock.

Working through KDS300 PE configuration for the  MKL26Z128VFT4, its wanting a 48Mhz clock.

I'm not clear on the basics of the MCG modes as to what I'm looking for - what multipliers I can try for, and whether the L26Z is designed to do this from 32Khz xtal.

I have run through setting up a USB MSC device for the FRDM-K20 following the excellent examples from McuOnEclipse, and it worked for setting up for a 24Mhz clock.

So can I set up the L26Z for the USB MSC device clock of 48Mhz or 24MHz ?

Here is what i've tried

I create a Clock Config 1 with Clock Source Setting 1- for normal mode

I use Clock Config 0 with Clock Source Setting 0 for USB mode

I set the MCG Mode to FBI to be able to the use the Fast Internal Clock (4Mhz/2Mhz), This then allows be to generate a 47.972353Mhz clock - (close to 48Mhz)

The CPU component is error free, however I can't get the USB Component to accept the 47.97352Mhz for its 48Mhz clock

Any help appreciated

thanks

Update: Actually I was close. For the USB_LDD component, I needed to input a 48Mhz clock frequency with an error that allowed the 47.972Mhz clock to be selected. ( I was double clicking the available frequency and then inputting the error - which it didn't like)  So I wonder if anybody has some comments as to if this should work?

pastedImage_0.png

pastedImage_1.png

Message was edited by: Neil Hancock

Tags (2)
1 Solution
1,846 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Neil,

I am sorry, but you can not use FLL to generate the ref clock for USB, because FLL is out of spec. Please refer to the following for details.

44.png


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

10 Replies
1,847 Views
neilhancock
Contributor IV

One further observation - the USB_CLKIN is accessed on PTE26 and PTA5 - neither of which is available on QFN48 adn QFN32 . I'm using QFN48 - so means I can't use USB on this device.

0 Kudos
Reply
1,847 Views
mjbcswitzerland
Specialist V

Neil

It depends on your overall design. The USB_CLKIN is used to supply a dedicated 48MHz USB clock to the USB controller (rather than it being derived from the PLL). It is rare to actually see designs using this (alternative) input.

If only USB device is required I would always go for a KL27 and a 32kHz crystal for good time base accuracy and certifiable USB operation, with least components.

Regards

Mark

Kinetis: µTasker Kinetis support

KL26: µTasker Kinetis FRDM-KL26Z support  / µTasker Kinetis Teensy LC support

KL27: µTasker Kinetis FRDM-KL27Z support  / µTasker Kinetis Capuccino-KL27 support

USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF

Composite USB: µTasker USB Device Configuration

RTC/Time Management: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply
1,847 Views
neilhancock
Contributor IV

Hello Mark

This thread is about MKL26Z and the Usb Clocking - so as has been pointed out if using a USB (Otg) on the MKL26Z then as per Figure 5-6 then MCGFFLCLK is not recommended to be used.

I guess maybe I didn't state it right, I haven't found a way to use the MCGPLLCLK generate 48MHz from a 32Khz Xtal - but maybe I'm wrong.

So if no PLL then the only stable clock is from the USB_CLKIN

Which from my reading the data sheet doesn't appear on the QFN48 and QFN32

Agreed for USB device then the MKL27Z is viable, however it is newer, doesn't have a lot of other people who have tested it particularly the USB stack so has a higher risk for a product, rather than an experimental platform,. So my sense is better to have a new device season for a period before using it. 

I see you are planning on being a SOM vendor for a MKL27Z, but google can't translate it so I've no idea what it says.

Thanks for the thoughts

0 Kudos
Reply
1,847 Views
mjbcswitzerland
Specialist V

Neil

As has already been concluded (for the KL26), it is not possible to use the FLL as USB source due to its high jitter. 32kHz can also NOT be used by the PLL since the PLL requires an input reference between 2MHz and 4MHz.

This means that you can only use a higher frequency crystal or osillator (8 MHz is typical).

This is the MCG diagram for the KL26 with the only option that you have for the chosen chip if you want to also have high accuracy RTC operation and USB:

pastedImage_4.png

Note that the user manual forgets to show the PLL input divided (1..25) so EXTAL 2M, 4MHz, 6MHz, 8MHz etc. are in fact all suitable (for 48MHz core and USB).

You will need an external 32KkHz osciallator on RTC_CLKIN.

This is a standard setup for the KL26 in projects like you are planning.

If you prefer to save the 32kHz oscillator and don't require highly accurate RTC operation and wake up for low leakage modes you can still use the LPO to clock it. Or you can just not use the RTC since it can easily be accurately performed in SW from the main clock, including retaining the time/data across SW resets (the uTasker project has this option to completely emulate a more capable RTC like this without any HW RTC requirements).

I don't think you need to be worried about the KL27 in comparison to the KL26 for USB. The USB controller is identical apart from the new 48MHz IRC. I have used it in many newer processor without any issues and Freescale has proven USB certification on K22 and K64s, which have the (exact) same design as the K27.

>>I see you are planning on being a SOM vendor for a MKL27Z, but google can't translate it so I've no idea what it says.
I am not sure but you may be referring to the "Coffeebrain Capuccion-KL27". This is a project developed at the Universidad de Los Andes in Colombia which I am not involved with directly - I don't know whether they are selling the board or just using them for university course work but the uTasker project was used by them and the board is supported in it (and simulated) so that they can make use of USB-MSD and the SD card. From circut diagram to complete working project took about 2 hours - I never saw the real board because I just plugged it into the simulator, sent the setup and they build the project with KDS and verified that all worked successfully on the real hardware.

Regards

Mark

Kinetis: µTasker Kinetis support

KL26: µTasker Kinetis FRDM-KL26Z support  / µTasker Kinetis Teensy LC support

KL27: µTasker Kinetis FRDM-KL27Z support  / µTasker Kinetis Capuccino-KL27 support

USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF

Composite USB: µTasker USB Device Configuration

RTC/Time Management: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,847 Views
neilhancock
Contributor IV

Wow thanks for the tips.

I have done the software simulated wall clock from periodic interrupt - got it in a field product and worked well - but that's why I never want to do it again and have it be a nag in the system test phase. So nice to have a simple counter in the hardware and SHOULD be easy to do low power with it. Reliable time is a critical feature with a system that may not be connected to the internet.

Appreciate the pointing out the other USB 48MHz options that I had missed. Occasional USB OTG is a would be nice feature but power usage is critical in the non-USB connected times, so I can set up for some trials  and check power consumption.

So for anybody else trying this,  I come up with external low power 32Khz Xtal  - SIT1552AI-JF-DCC-32.768D that connects RTC_CLKIN

Currently I'm using a small 32Khz XTAL 9HT10-32.768K and for a similar footprint this trades up to a slightly wider but same length footprint 8Mhz NX3225GD-8MHZ-STD-CRA-3

0 Kudos
Reply
1,847 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Neil,

I am sorry, but you can not use FLL to generate the ref clock for USB, because FLL is out of spec. Please refer to the following for details.

44.png


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,847 Views
neilhancock
Contributor IV

Hi Kan

Really appreciate a quick response and pointing out the issue.

So I guess to meet the jitter spec it would be to use an external 48Mhz, perhaps like the KC2520B48.0000C10E00

(KC2520B48.0000C10E00 AVX Corp/Kyocera Corp | 478-4782-1-ND | DigiKey )

The external Oscillator also costs 1-2pins - one for the CLKIN and potentially another for switching the oscillator to Standby.

or shift to the MKL27Z - which has an internal accurate oscillator that works.

thanks

Neil

0 Kudos
Reply
1,847 Views
mjbcswitzerland
Specialist V

Neil

The KL26 Freedom board uses a 8MHz crystal, which is adequate for the USB specification (both device and host).

A KL27 can use its internal 48MHz IRC for device mode (but not host). This oscillator is not particulary "accurate" but is synchronised/locked to the host's SOF in order to meet the specification.

If you are using the 32kHz crystal for timekeeping beware that it won't operate as a (full) real-time clock since the RTC in the KL is reset when there is a system reset. If you need to maintain time/date in low leakage modes it is recommended to use a 32kHz low power oscillator on the RTC_CLKIN pin. Shoud the time keeping only be required during normal operation, the 8MHz crystal is also adequate and the RTC doesn't offer any real benefits. More details at µTasker KL RTC Support

Regards

Mark

Kinetis: µTasker Kinetis support

KL26: µTasker Kinetis FRDM-KL26Z support  / µTasker Kinetis Teensy LC support

KL27: µTasker Kinetis FRDM-KL27Z support  / µTasker Kinetis Capuccino-KL27 support

USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF

Composite USB: µTasker USB Device Configuration

RTC/Time Management: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,847 Views
neilhancock
Contributor IV

Hello Mark

Thanks for the comments - so yes looking to use the RTC and have it ride through system resets, though  if the chip/RTC looses power it is POR and RTC is reset.

Looking to have a USB Device

So  I've chosen to run off 32KHz for the low power RTC - and have the FLL boost the CPU cycles system clock for when it is needed - the system clock doesn't need to be accurate - except of course for USB device.

The FRDM-KL27Z board says it has a 32KHz oscillator - though I couldn't find schematics for it.

So just checking if you've found something when using the devices

KL26P...SF4RM Sect 3.8.4.1 RTC is reset on POR only

KL27, the KL27P ..F2RM says sect 29.1.1.  "RTC is reset on POR Only."
similarly in Table3 - RTC only affected by POR

and in '29.2.2 Modes of operation
The RTC remains functional in all low power modes and can generate an interrupt to exit any low power mod
AN4997 Kinetis Migration to "KL27" from earlier KL micros - doesn't identify any changes with the RTC.

It does identify significant changes in the clocking, "MCG_Lite"  to be able to get USB clock spec (by whatever magic) and RTC

So be interested to hear of any real world experience where you find the RTC reset in other than POR.

0 Kudos
Reply
1,847 Views
mjbcswitzerland
Specialist V

Hi Neil

I mis-wrote concerning the SW reset, since the RTC holds its value - although won't count if the clock actually stops during the reset.

Essentially it means that for full RTC operation a low leakage mode needs to be used since there is no back-up battery domain, abd the clock must be ensured in this low leakage mode.

If you are always powered and don't mind losing time on a power cycle, short SW resets are generally only a 'glitch' to the RTC.

You can find the FRDM-KL27Z circut diagrams on the FRDM-KL267Z web page - go to "downloads" rather than douments since the schematics tend to be there. I use the KL27Z with 32kHz crystal for main clocking (multiplied to about 48MHz) and as RTC source, plus USB-MSD on SD card (form the 48MHz IRC) so generalyl the KL27 is superior to the KL26 in terms of crystal efficiency.

When I do the same with the KL26 I use an 8MHz crystal for main clock and USB and an external low power oscillator for the RTC (when timing is not critical I use the 1kHz PO for RTC clocking, but it i fairly inaccurate over time).

You can in fact test complete projects at the links below (for both KL26 and KL27) which also include all low leakage mode support too in case periods of sub-uA consumption are required (with continued RTC and alarms). The K27 one include USB-MSD and SD card or mutiple USB-CDCs.

In case you need a specific setup to test on your HW tell me since the project is processor independent and can be configured for any device, clocking/RTC option, and for almost any USB-MSD / composite USB combination in a few minutes (since I can simulate the complete operation it usualy can be verified without real HW to check on).

Regards

Mark

Kinetis: µTasker Kinetis support

KL26: µTasker Kinetis FRDM-KL26Z support  / µTasker Kinetis Teensy LC support

KL27: µTasker Kinetis FRDM-KL27Z support  / µTasker Kinetis Capuccino-KL27 support

USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF

Composite USB: µTasker USB Device Configuration

RTC/Time Management: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply