I need USB CDC Serial to commmunicate with PC using FRDM-KL46Z

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

I need USB CDC Serial to commmunicate with PC using FRDM-KL46Z

2,620 Views
marceli1
Contributor III

I need USB-CDC Serial code example for FRDM-KL46Z. Processor Expert in CW seems not supporting CDC type USB.

Labels (1)
11 Replies

2,040 Views
mjbcswitzerland
Specialist V

Hi Joe

You can get FRDM-KL46Z USB-CDC from http://www.utasker.com/kinetis/FRDM-KL46Z.html#CDC1

It is configurable for 1 to 6 USB-CDC VCOMs (with optional USB-CDC<->RS232 bridges) or can be combined for composite devices, including RNDIS, Audio, HID, and MSD.

Regards

Mark
Kinetis for professionals: http://www.utasker.com/kinetis.html

2,040 Views
marceli1
Contributor III

Hi Mark,

I am currently using FRDM-KL46Z USB-CDC serial. How to configure it to FRDM-KL46Z USB-HID still using Processor Expert?

Regards,

Marceli

0 Kudos
Reply

2,040 Views
mjbcswitzerland
Specialist V

Marceli

I do USB-CDC and USB-HID by enabling
USE_USB_CDC
and

USE_USB_HID_MOUSE (or USE_USB_HID_KEYBOARD or USE_USB_HID_RAW) together.

Finished.

No idea how to do it in PE - I suppose first you need to find out whether PE contains the capability and if not wait until some one adds it for you, or you can possibly add it yourself.

I have quickly added a binary that you can try on the FRDM-KL46Z if you like that is a USB-CDC and USB-HID mouse composite (the mouse movement is controlled by the board's accelerometer and SW1 acts as mouse left button). This took me two minutes to configure and build for the board.

http://www.utasker.com/kinetis/FRDM-KL46Z.html#A-Mouse

Regards

Mark

0 Kudos
Reply

2,040 Views
marceli1
Contributor III

Hi Mark,

I can modify "USB1:FSL_Stack" component into Device Class: HID Keyboard Device (HIDK) or HID Mouse Device (HIDM), which for Keyboard has more functions to us, coming with Tx2:RingBuffer[<name>] inspector. Both have only to send generated function by PE. I need use it as platform to create own Control Class with sending and also receiving responding data packets. It need be HID Joystick Control Device (HIDJC) which includes also receiving data from the application. Maybe for this HID Raw Device class is best option?

Regards,

Marceli

0 Kudos
Reply

2,040 Views
mjbcswitzerland
Specialist V

Hi

I have the same RAW HID functionality as described here.
https://www.pjrc.com/teensy/rawhid.html
and
https://www.youtube.com/watch?v=iMuNbAv61OA
There was someone who asked about RAW and Joystick here:
https://forum.pjrc.com/threads/40445-Teensy-3-2-Joystick-with-Raw-HID

Regards

Mark

0 Kudos
Reply

2,040 Views
BlackNight
NXP Employee
NXP Employee

I'm using a set of Processor Expert components availble on SourceForge (McuOnEclipse - Browse /PEx Components at SourceForge.net ), see https://mcuoneclipse.com/2014/10/21/mcuoneclipse-releases-on-sourceforge/  how to install them. There is a tutorial about it here: https://mcuoneclipse.com/2012/10/07/tutorial-usb-cdc-with-the-kl25z-freedom-board/ 

I have attached for you the full CodeWarrior example project for it: you can use this USB CDC either bare metal or with FreeRTOS. This and other projects are available on GitHub:

mcuoneclipse/Examples/CodeWarrior/FRDM-KL46Z at master · GitHub 

On Windows you need a .inf file for the driver, located in the 'Documentation' folder. Make sure you carefully read and follow the cdc.inf_readme.txt

I hope this helps,

Erich

2,040 Views
marceli1
Contributor III

Hi Erich,

Yes it helps much using training and example in attachment for mine KL46Z processor. Only in each case on CW10.6 compilation shows warning: C:/Freescale/CW MCU v10.6/MCU/ARM_GCC_Support/ewl/EWL_C/include/stdbool.h #warning "EWL support for C99 is not enabled". Why it happens? For the project I imported recent PE Components 2016-09-21.

Regards,

Marceli Firlej

0 Kudos
Reply

2,040 Views
BlackNight
NXP Employee
NXP Employee

Hi Marceli,

you can ignore that warning: it is about using the EWL embedded libraries in combination with C99. Because C99 comes with extra standard defines like bool, they can conflict with other local typedefs for code which can be used for C89 and C99 compiler settings.

I hope this helps,

Erich

2,040 Views
marceli1
Contributor III

Hi Eric,

In mine FRDM-KL46Z I successfully implemented USB Serial CDC with COM port, however in SDA DEBUG mode it opens as COM4 (i.e.) but it can not run in debug mode hanging on while loop the line:

while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { }

Is any way to setup CW10.7 for debug mode to read USB ports?

Regards,

Marceli Firlej

0 Kudos
Reply

2,040 Views
BlackNight
NXP Employee
NXP Employee

Hi Marceli,

USB CDC is running on the other USB port of the board, not on the OpenSDA one. The OpenSDA port is connected to the normal UART of the KL46Z. If you want to use the USB CDC, you have to connect with another cable on the second USB port.

Erich

0 Kudos
Reply

2,040 Views
marceli1
Contributor III

Hi Erich,

Thank you, now its programming and debugging with both USB connected cables. I can easy debug USB communication data transmitted from PC.

Regards

Marceli

0 Kudos
Reply