Finally my Freescale TWR-K21F120M board arrived 🙂
For the next generation of INTRO Zumo robots I’m evaluating a new ‘brain’: more processing power, more FLASH, more RAM, more of everything 😉
The board comes assembled, with one micro-B USB cable, a CR2025 coin cell battery and quickstart guide.
💡 Be very careful with these micro-B USB connectors! The cables lock into the connector, and some force is used to pull them off. As the connectors are SMD ones, they easily could get ripped of the board if you are not careful!
The board has 4 user LED’s, potentiometer, an accelerometer (MMA8451Q), extension sockets (TWRPI) two push buttons, and on the back side an SD card socket:
On the back side you see as well the S08JM60 CPU responsible for the onboard debug interface (OSJTAG).
💡 The OSJTAG is not very fast. I recommend to use an external TAP (P&E Universal Multilink or Segger J-Link) with the onboard JTAG header.
The heart of the board is the MK21FN1M0V12 in BGA package:
In a small and tiny package I get
- ARM Cortex-M4F with Hardware Floating Point Unit
- Up to 120 MHz
- 1 MB FLASH
- 128 KByte SRAM (splitted up in two 64 KByte areas)
💡 I probably will go with a QFN package, as even if I manufacture the new robot board outside, that BGA package is not very hobby friendly.
So plenty of space and performance for my bot :-).
The onboard OSJTAG interface features a serial-to-USB bridge. As I do not plan to add the OSJTAG debug interface on my board, and as I need a serial connection to my robot, my first concern was to bring up USB CDC on the K21F120M.
The port of the Freescale USB Baremetal stack I have has not supported that K21F120M yet, so I have extended the FSL_USB_Stack component for the K21F120M:
My USB CDC component uses ring buffers for Tx and Rx:
The implementation was limited to use a byte as buffer entry, and a buffer was only able to have up to 256 elements.
Now the component has been extended for different element size, increased buffer size and an option to have it using reentrant or non-reentrant access to the buffer:
USB CDC device is working fine now for the K21F120M, and I made a quick port of my robot application to the K21F120M which is looking good. The USB HID keyboard and mouse plus MSD Host should be working too, but I have not tested it yet. I’m still not decided on the CPU, and I need to have a look at the Kinetis K22 too, as that one even looks a better choice for what I’m looking for?
My current project and components are available on GitHub:
Happy Evaluating 🙂
In the first heading you mentioned the board as FRDM and not TWR. I think it is a little mistake.
ups! Dealing too much with FRDM boards recently, I guess 😉 Thanks for reporting this, I have fixed it now. Oh, yes, I wish there would be a FRDM board for this device too 🙂
Pingback: Processor Expert Driver Suite V10.3 Available | MCU on Eclipse
Here is how to make your own k22 freedom board.
Take a FRDM-KL25Z board and replace the processor with a mk22fn1m0vlk12. Then connect PTB11 and PTC13 to Vcc, PTB10 and PTC12 to Gnd.
Cool! I have a dead KL25Z on a FRDM-KL25Z board, so I might try this out.
Hi Erich, I testing MK22,
question: CDC send String( “mystring”) = ok
send Buffer( hex ) to pc, not send
ex: CDC1_App_Task(mybuf, 16) or CDC1_SendDataBlock( mybuf, 16)<–not send
I do not have a MK22, but I tried with KL25Z (should not matter) and it works for me:
CDC1_SendBlock((unsigned char*)”hello?\r\n”, sizeof(“hello?\r\n”)-1);
Keep in mind that the buffer for
must be different for the buffer you use for SendBlock().
Hi Mr. Styger
I am currently trying to integrate your USB-stack into my solution on TWR-K21F120M board.
Unfortunately the code crashes (bus fault) at line 237 in USB0.c file. I think there is something wrong with the settings of the component. Can you send me the right ones?
I am using Eclispe with PE-plugin and IAR for debugging. I do not have a license for Codewarrior, so I am not able to extract the settings from your example project.
I found the problem: In the USB0 component the “Clock gate” under settings must be enabled..
Thank you anyway, your homepage helped me a lot up to now.
ah, ok, good you found it 🙂
Pingback: USB CDC with the FRDM-K64F, finally! | MCU on Eclipse
So I modified this project to attempt to test the USB on a custom K22 board, but I can’t get the cdc.inf file to install properly in Windows 7. I am able to build and flash the program onto the board, and run the board. The USB device shows up as ‘Unknown device’, and when I attempt to follow the steps to install the cdc.inf file, I can get to the point of selecting the .inf file. Windows then gives me an error stating that the folder does not contain a driver that is compatible with the device. It notes that if the folder does contain the driver for the device, ensure that the driver is compatible with x64 Windows. Any ideas?
Which version of my Processor Expert USB components are you using? I have found that for the K64F (https://mcuoneclipse.com/2014/10/25/usb-cdc-with-the-frdm-k64f-finally/) the MMU needs to be disabled. Same applies to the FRDM-K22F. So are you using the K22F which is on the FRDM-K22F board, or the ‘old’ K22F? I ask because even if they have the same name, they are *different*.
The other point is that usually if the USB enumeration does not work, then there is a problem with the clock setup to the USB module.
I have added the FRDM-K22F to the USB stack, but I have not released it yet (there was no time last week-end for a release).
I hope this helps,
I’m using the latest from here: https://github.com/ErichStyger/McuOnEclipse_PEx. I’m actually using a K22FX512VMC12. I set up the clock as described in the K64F link. If it matters, I’m using KDSv1.1.1. I tried copying the components and source code into a KDS project (since I don’t have the CW libraries to link to), and I was able to get the device to work (albeit with the rather interesting behaviour of echoing back every character instead of every line). I’ll double-check the clock settings, since these threw me for a loop when I first tried this on the TWRK21.
Ok, so it seems that the USB stack is working. Are you following the Documentation\cdc.inf_readme.txt to the letter? The issue is that you need to manually select the driver, and *not* let Windows pick it. I have pasted the instructions below.
readme for USB CDD driver installation (cdc.inf)
This cdc.inf is based on following forum thread:
For your windows system, you need to make sure drivers are correctly installed.
For this go into your Windows Device manager. Your CDC device probably shows up as “JM CDC DEMO”.
Update the driver and point to the generated cdc.inf file in the project documentation folder.
Important: follow the steps below to install/update the driver:
– Go to the Device manager and identify the device. Perform an ‘update driver’
– IMPORTANT: Select ‘Browse my computer for driver software’
– IMPORTANT: select ‘let me pick from a list of device drivers on my computer’
– use ‘show all devices’, use ‘have disk’ and to browse to the cdc.inf file
– this will show up as ‘Freescale CDC device’ 🙂
See as well following post:
Ouch. I just realized that I erred in my previous post. When I tried copying the files and whatnot over from this project, I copied them into another project for the TWR-K21F120. That was what worked (with quirks). The K22 seems to get caught in the enumeration loop and never leave.
I have sent to you by email my K22 robot project (K22FX512, see https://mcuoneclipse.com/tag/zumo/) which uses USB CDC. I hope this helps,