Hi
I just started writing code to the MKL27Z256VFT4 processor. So far i have installed KDS 3.0.0 with 3.0.1 updates and KSDK 1.2.0 in Linux. I use PEx to generate kode with FreeRTOS, I2C ect. for the project and everything is working as I would expect. I can program the chip and debug it using a jtag device.
The application I'm writing is reading data from some sensors and should then send them to a PC via the USB port from the KL27 processor. From what I have read that I need to setup the USB device as a CDC. I have found a lot of examples on how to setup the port for mouse, keyboard and storage devices (HID and MSD) from similar chips but that is not really what I need. I hope you can help me how to setup the USB and it would be nice if it can be done using PEx in KDS.
Kind regards
已解决! 转到解答。
Hi Martin,
In same KSDK software, you can find CDC examples for FRDM-KL27Z and for FRDM-KL43Z (which is compatible with your KL27Z256 chip).
You can look at them at: <KSDK_PATH>/examples/<board>/demo_apps/usb/device/cdc
If you have any doubt about CDC example, please let me know it.
Regards,
Isaac
Hi Isaac
How is it going with the how-to document from your answer before?
Now that i already have a project generated in PE and want to include to CDC USB functionalities from the example above how is the easiest way to do that? Should i include the fsl_usb_framework and fsl_usb_descriptors in PE or manually?
The example is with bm and I'm using FreeRTOS, is that a problem and/or how to solve it?
Hello Martin,
Sorry for late response, attach you will find the steps needed to clone USB library for KL27Z4 derivative.
About your CDC device, I have a document that shows how to create a new USB project (HID class) with processor expert support from scratch that basically it uses the application files as KSDK examples (so CDC support is not added by PEx), you can look at this document at: Creating a New USB project with KSDK and Processor Expert support in KDS
If we follow this document, we can use FRDM-K64F CDC example as reference in order to have a FreeRTOS and CDC example in KL27Z.
I hope this can help you,
Best Regards,
Isaac
Hi Isaac
Thank you very much, I think it is very close now.
If I select bm from PE then it works, but if I change to FreeRTOS then the variable "start_app" will never be true and start the virtual com app(main.c line 387). I think the problem is in the os abstraction file which PE is changing when generating code.
When changing from FreeRTOS to bm:
When changing from bm to FreeRTOS
I have attached my project if you would like to see it.
Kind regards
Martin
Hello Martin,
I've already noticed this situation, I also made a project to use PEx + FreeRTOS + CDC Example for FRDM-K64F in one project, but i got some errors on malloc function in FreeRTOS' abstraction, that is why in my project, device could not start. (malloc always returned NULL pointers), this is done due current heap scheme in FreeRTOS. (For More information, please check this post:Malloc not working in a task )
Please, try next modification:
Go to osa component and then to inherited component related to FreeRTOS:
Change Heap scheme and heap size as shown below:
After this, example code should work without problems.
I attach project created for FRDM-K64F.
Best Regards,
Isaac
Hi Martin,
In same KSDK software, you can find CDC examples for FRDM-KL27Z and for FRDM-KL43Z (which is compatible with your KL27Z256 chip).
You can look at them at: <KSDK_PATH>/examples/<board>/demo_apps/usb/device/cdc
If you have any doubt about CDC example, please let me know it.
Regards,
Isaac
Hi Isaac.
Thank you for your reply.
I have now imported:
"<KSDK>/lib/ksdk_platform_lib/kds/KL27Z4" and "<KSDK_dir>/examples/frdmkl27z/demo_apps/usb/device/cdc/virtual_com/bm/kds"
but after i build i get the following errors:
-Description Resource Path Location Type make: *** No rule to make target `/home/maskr/software/sdk/SDK_unpacked/KSDK_1.2.0/examples/frdmkl27z/demo_apps/usb/device/cdc/virtual_com/bm/kds/../../../../../../../../../lib/ksdk_platform_lib/kds/KL27Z644/debug/libksdk_platform.a', needed by `dev_cdc_virtual_com_frdmkl27z_bm_frdmkl27z.elf'. dev_cdc_virtual_com_frdmkl27z_bm_frdmkl27z C/C++ Problem
-make: *** No rule to make target `/home/maskr/software/sdk/SDK_unpacked/KSDK_1.2.0/examples/frdmkl27z/demo_apps/usb/device/cdc/virtual_com/bm/kds/../../../../../../../../../usb/usb_core/device/build/kds/usbd_sdk_frdmkl27z_bm/debug/libusbd_bm.a', needed by `dev_cdc_virtual_com_frdmkl27z_bm_frdmkl27z.elf'. dev_cdc_virtual_com_frdmkl27z_bm_frdmkl27z C/C++ Problem
-make: Target `all' not remade because of errors. dev_cdc_virtual_com_frdmkl27z_bm_frdmkl27z C/C++ Problem
Is there anything else I need to import or what did i miss?
/Martin
Hi Martin,
It is needed to compile the USB device library, as well as KSDK platform library for your specific target. For example, for FRDM-KL27Z you will need to compile:
And then, import your example code:
Compile it and download into your target.
Again, these libraries are specific for KL27Z644 and not KL27Z4 (as you can see, there is no usb library for this target) so you can make two things:
You can try using the first one while I can finish a basic document in how to do the second one.
I hope this can help you,
Best Regards,
Isaac