Hi Alexis,
Okay, after the last two days of pulling my hair out with boards loaded with the processor that I want to use, I have a USB CDC Device app working and I can recreate it on my test set up so I think the question is answered.
The solution was to look at the TWR-K21M120 - I was trying the FRDM-K22F and FRDM-K64F previously, both of which have a 2.7.0 SDK, (when I was reading through other people's suggestions, this seemed to be the right approach). The TWR-K21M120 is actually be Freedom/Tower board that is closest to the MK22FN1M0AVLL12 that I'm testing with and the MK22FN1M0AVMD12 that I want to use in the final product AND has the same SDK.
The TWR_k21M120 SDK is 2.3.1 (which is the same level as the SDK for MK22FN1M0Axxx12 parts that I am using) and the "twrk32f120m_dev_cdc_vcom_freertos" can be loaded directly into the MK22FN1M0AVLL12 and run that on the board I'm using for test (I didn't think that loading the binary file for an MK21 was possible on an MK22 due to the ID bits in the processors, but I'm definitely NOT complaining). After seeing the MK21 code run on my test board I tried the FRDM-K22F and FRDM-K64F apps and while they can be downloaded into the MK22FN1M0AVLL12 but don't seem to run; I know that the clocking & SRAM differences for the FRDM-K64F would not allow it to run but I don't know what the issue is wth the FRDM-K22F although it may be clocking there as well.
The secret seems to be to not look at the Freedom/Tower board that seem to best match the processor you want to use, but the ones that have the same SDK that is available for the processor you want to use.
A couple of points that I would appreciate you answering:
1. The "twrk32f120m_dev_cdc_vcom_freertos" create "osa" and "usb" folders that need to be copied into the final application and these options aren't available in the "New Project" dialog (even though they are in ths SDK .zip file) - why is that? Shouldn't all the options that I select when making the SDK before downloading it be available when I'm making a project?
2. I cannot figure out any way to generate the same "board" clock_config.c/.h files usign the clock tool in MCUXpresso IDE (which is why I copy them in directly - fortunately I'm using a 8MHz Crystal while the Tower board uses a ceramic resonator. Is there a document that explains how to do this?
So, based on five days plus of experimenting and trying to figure out what's happening for somebody looking to do what I did with a Kinetis part (I won't say that it is an easy process or would work with any other device), I've put down the steps I've come up with for getting my device to run the USB CDC Device application and using MCUXpresso IDE and I'm going to mark the question answered so that they don't skip over when they have the same question that I had.
Again, thanx for replying and suggesting fixes.
myke
This is based on the "twrk21f120m_dev_cdc_vcom_freertos" example project.
- Load in the SDK 2.3.1 for TWR-K21F120M
1. Create Project:
- MK22FN1M0Axxx12
Name: MK22_FreeRTOS_USB_#TWRK21
Device Packages: MK22FN1M0AVLL12
Operating Systems: FreeRTOS
Drivers: clock
- common
- flash
- gpio
- port
- sim
- smc
- sysmpu
- uart
CMSIS Drviers:
Utilities: assert
- debug_console
Middleware:
2. Setup USB and IO Pins
- Pin 10: USB0_DP USB_DP
- Pin 11: USB0_DM USB_DM
NOTE: No Clock Specification
3. Build and test.
4. Delete "FreeRTOSConfig.h" in "source" folder
5. Create "source folders" for:
- osa
- usb
And copy in the contents from the respective folders in "twrk21f120m_dev_cdc_vcom_freertos"
6. Replace in the "board" folder with the values from "twrk21f120m_dev_cdc_vcom_freertos" for:
- clock_config.c
- clock_config.h
NOTE: Have to figure out if I need to change the capacitor values for the clocks
7. Open "Properties"=>"C/C++ Build"=>"Settings"=>"Preprocessor" and match the following terms:
__REDLIB__
CPU_MK22FN1M0AVMC12_cm4
CPU_MK22FN1M0AVMC12
_DEBUG=1
USB_STACK_FREERTOS
USB_STACK_FREERTOS_HEAP_SIZE=32768
FSL_RTOS_FREE_RTOS
SDK_DEBUGCONSOLE=0
CR_INTEGER_PRINTF
PRINTF_FLOAT_ENABLE=0
__MCUXPRESSO
__USE_CMSIS
DEBUG
8. Open "Properties"=>"C/C++ Build"=>"Settings"=>"Includes" and match the following includes:
"${workspace_loc:/${ProjName}/board}"
"${workspace_loc:/${ProjName}/source}"
"${workspace_loc:/${ProjName}/}"
"${workspace_loc:/${ProjName}/usb/device/source/khci}"
"${workspace_loc:/${ProjName}/usb/include}"
"${workspace_loc:/${ProjName}/osa}"
"${workspace_loc:/${ProjName}/drivers}"
"${workspace_loc:/${ProjName}/CMSIS}"
"${workspace_loc:/${ProjName}/freertos/include}"
"${workspace_loc:/${ProjName}/freertos/portable}"
"${workspace_loc:/${ProjName}/utilities}"
"${workspace_loc:/${ProjName}/startup}"
"${workspace_loc:/${ProjName}/usb/device/class/cdc}"
"${workspace_loc:/${ProjName}/usb/device/class}"
"${workspace_loc:/${ProjName}/usb/device/source}"
"${workspace_loc:/${ProjName}/usb/device/include}"
9. Copy following files from "sources" of "twrk21f120m_dev_cdc_vcom_freertos" in to "source" of the new project
- configFreeRTOS.h
- usb_device_config.h
- usb_device_descriptor.c
- usb_device_descriptor.h
- virtual_com.c
- virtual_com.h
NOTE: "twrk21f120m_dev_cdc_vcom_freertos" has a "source" folder with the "semihost_hardfault.c" file, ignore
10. Modify "MK22_FreeRTOS_USB_#TWRK21.c" by "#ifdef" out the "main" method
11. Build and test