Change processor in SDK example program

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

Change processor in SDK example program

Jump to solution
1,092 Views
GaryOlmstead
Senior Contributor I

I am working with the K60 in the 100 pin LQFP package.  I've gotten around to starting the USB portion of the project.  I would like to work with the USB VCOM example program in the K60 SDK, but it's for the 144 BGA package.  I tried reassigning the MCU package in Project >> Properties >> C\C++ Build >> MCU Settings, but although it accepted the change, absolutely nothing changed.  I've had mixed success in the past by creating new projects and dragging the files from other projects, so I am wondering if there's an easier and less time consuming way.

Gary Olmstead

0 Kudos
1 Solution
1,017 Views
myke_predko
Senior Contributor III

Hi GaryOlmstead‌,

You're going to have to do more just copy in the files - sorry if I left that impression. 

When you're copying in files you have to make sure that you:

  1. Create "source folders" (not normal folders) in the MCUXpresso project.  You can't just copy the folders over - they MUST be "source folders".  After creating the "source folders", I copy in the contents from the example project.  
  2. Check the preprocessor flags and make sure that the appropriate ones for the features you want (ie USB) are included.  
  3. Make sure all the new folders are listed in the build includes.  

In my situation, when I'm copying in the CDC device files from the Tower K21F board to mine (K22), I have to do the following steps:

1. Create "source folders" for:
- osa
- usb
And copy in contents from respective folders from the previous project

2. 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=53248
FSL_RTOS_FREE_RTOS
SDK_DEBUGCONSOLE=0 
CR_INTEGER_PRINTF
PRINTF_FLOAT_ENABLE=0
__MCUXPRESSO
__USE_CMSIS
DEBUG

3. 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}/drivers/freertos}"
"${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}"

It may seem like a lot of work to do this, but with a notebook app and cut and pasting the information in the example project "Properties" and doing some experimenting you can figure out what's needed to build the project in fairly short order.  

Again, apologies for not indicating that you have to do more than just copy the files.  

myke

View solution in original post

0 Kudos
4 Replies
1,017 Views
myke_predko
Senior Contributor III

Hi GaryOlmstead‌,

This was discussed previously here in Compilation error.  MCUXpresso does not take changes erll to a project after it's created - I've hit this snag a couple of times when I've selected the wrong part number when creating a project.  When I've made these mistakes, it's usually obvious very quickly as the project will no longer build and I delete the project and start over.  

I think the work to properly allow configuration updates the project once it exists is *very* hard and complex - I don't think this is something that you can reasonably expect of the MCUXpresso maintainers.  

I think the best thing that you can do is to start with the base feature you want to use (I start with USB, which is probably the same as you) from a Freedom/Tower board that is similar and has the same SDK as the part you want to use (this is not always possible or the corresponding example board may not be what you expect it to be) and then copy it into the part you want to use.  This can be tricky and I suggest you document everything you do so when the inevitible problems happen, you can go back and figure out what you did wrong or try something different.  

I wish I had a better answer for you but if you follow a rigorous process in selecting the example code to copy and bringing it into your project you should be fine.  

myke

0 Kudos
1,017 Views
GaryOlmstead
Senior Contributor I

HI Myke --

 Creating a new project and importing all the files was exactly what I i did first.  The problem is that the compiler can't find files that are visible in the project list. For example, usb_device_cdc_acm.c can't find usb_device_config_h, which is in another folder, but that didn't stop this code in a copy of this document for the Tower card.  Likewise, several files can't find "usb.h".

I guess I'll try copying all the files into one big folder.

Thanks for your help.

Gary

0 Kudos
1,018 Views
myke_predko
Senior Contributor III

Hi GaryOlmstead‌,

You're going to have to do more just copy in the files - sorry if I left that impression. 

When you're copying in files you have to make sure that you:

  1. Create "source folders" (not normal folders) in the MCUXpresso project.  You can't just copy the folders over - they MUST be "source folders".  After creating the "source folders", I copy in the contents from the example project.  
  2. Check the preprocessor flags and make sure that the appropriate ones for the features you want (ie USB) are included.  
  3. Make sure all the new folders are listed in the build includes.  

In my situation, when I'm copying in the CDC device files from the Tower K21F board to mine (K22), I have to do the following steps:

1. Create "source folders" for:
- osa
- usb
And copy in contents from respective folders from the previous project

2. 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=53248
FSL_RTOS_FREE_RTOS
SDK_DEBUGCONSOLE=0 
CR_INTEGER_PRINTF
PRINTF_FLOAT_ENABLE=0
__MCUXPRESSO
__USE_CMSIS
DEBUG

3. 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}/drivers/freertos}"
"${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}"

It may seem like a lot of work to do this, but with a notebook app and cut and pasting the information in the example project "Properties" and doing some experimenting you can figure out what's needed to build the project in fairly short order.  

Again, apologies for not indicating that you have to do more than just copy the files.  

myke

0 Kudos
1,017 Views
GaryOlmstead
Senior Contributor I

Hi Myke --

I got it working, or at least it compiles and runs.  Now I have to figure out what it is supposed to do.

I should have said that I imitated the structure of the source code exactly, meaning not only source files but also header files.  To get it to compile, I had to copy some header files from one folder to another, meaning I have two copies of four or five header files.

0 Kudos