element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Freedom development platform
  • Products
  • Dev Tools
  • Freedom development platform
  • More
  • Cancel
Freedom development platform
Documents Codewarrior Tutorial for FRDM-K20D50M : USB CDC driver
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Freedom development platform to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: FreescaleTools_and_Software
  • Date Created: 14 Jun 2013 7:32 AM Date Created
  • Last Updated Last Updated: 14 Jun 2013 8:01 AM
  • Views 858 views
  • Likes 0 likes
  • Comments 2 comments
Related
Recommended

Codewarrior Tutorial for FRDM-K20D50M : USB CDC driver

This tutorial was extracted from Erich Styger blog http://mcuoneclipse.wordpress.com with his agreement.

image image

   

   

Good news for everyone owning the FRDM-K20D50MFRDM-K20D50M board: I have extended the FSL_USB_Stack with USB CDC device class support for the K20D50M :-) .

     

USB CDC Test Application with the FRDM-K20D50M 

USB CDC Test Application with the FRDM-K20D50M

  

 

Demo Application

  

The demo projects is made with Processor Expert components so it can be easily copied or ported to another board:

    

FRDM-K20D50M USB CDC Application Components 

FRDM-K20D50M USB CDC Application Components

 

I have created a demo application which echoes the entered text back on the console, with incrementing a counter:

   

USB CDC Test Application with the FRDM-K20D50M 

USB CDC Test Application with the FRDM-K20D50M

    

FSL_USB_Stack with FSL_USB_CDC_Device

With just two additional Processor Expert components, it is possible to add USB CDC functionality to an existing projects in just a few minutes. See “USB Component Splitted and Updated” for architectural information. The component has now added a Kinetis K20D50 option:

   

Kinetis K20D50 in FSL_USB_CDC_Device Component 

Kinetis K20D50 in FSL_USB_CDC_Device Component

 

 

:idea:  The FSL_USB_CDC_Device component features now an optional timeout feature. With this, it is easer to use the component in a bare-metal environment. It is using the extra ‘Timeout’ component which implements a timer based timeout to avoid stalling of the stack.
    

  

USB Clock Configuration

 

The most difficult part is the clock configuration. The USB block needs a 48 MHz clock to sample the 24 MHz USB signal. In the CPU component properties, I configured the System oscillator 0 to use the external 8 MHz crystal in Low power mode:

  

System Oscillator Settings 

System Oscillator Settings

 

The MCG Is set to PEE and 48 MHz PLL output clock:

     

MCG Settings 

MCG Settings

   

:!: It should be possible to use a 96 MHz PLL clock and then divide it down in the USB peripheral to a clock of 48 MHz. This is what I did first, and lost a lot of time, because this did not work :-( . I have not investigated it further, but this is either a bug in the silicon or in Processor Expert? 48 MHz without prescaler in the USB worked.

 

     

Derived from this, the system clocks are set up like this:

   

System Clock Settings 

System Clock Settings

 

In the Init_USB_OTG, the clock gate has to be enabled and the PLL/FLL clock to be used with 48 MHz:

  

USB Init_USB_OTG Settings 

USB Init_USB_OTG Settings

 

:!: From the settings it would be possible to use a 96 MHz PLL clock and then to scale it down ot 48 MHz. However, with this my device did *not* enumerate :-(

  

That’s it! The rest is just writing a small test application.

 

Sources

The above project/sources and last Processor Expert Components are attached to this post. The same repostitory hosts the updated FSL_USB_Stack and FSL_USB_CDC_Device Processor Expert components.

Happy CDCing :-)

Attachments:
ProcessorExpert_Beans.zip
FRDM-K20D50M.zip
  • cortex-m4
  • freescale
  • freedom_board
  • cdc
  • cortex-m3
  • Cortex-M
  • frdm-k20d50m
  • usb
  • codewarrior
  • microcontroller
  • development_board
  • arm
  • arduino
  • freedom
  • low-cost
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
  • bheemarao
    bheemarao over 8 years ago in reply to lorean

    Hi Dominique,

     

    Can i know which version of dev tool you are using i.e processor expert/KDS

    i checked on kds3.2 version below are the snap shot which shows controller K20D50 can be selected:

    image

    and

    image

    have a look on below links regarding USB CDC:

    https://community.nxp.com/thread/380656

    try downloading the components Download Components 2016-12-12.zip (9.1 MB) from below link:

    https://sourceforge.net/projects/mcuoneclipse/files/PEx%20Components/

     

    Best regards

    Bheema Rao

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • lorean
    lorean over 8 years ago

    sorry, i've already download the FSL_USB_CDC_Device but it doesnt give the option for cpu k20d50m. where can i get it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube