Warning!   Serious Bug in example code for Kinetis Example Code for CW10.1!

Discussion created by Guest on Jul 6, 2011

Beware! http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=K40&nodeId=01624698C9&fpsp=1&tab=Desi...

 

CW_MCU_V10_1_EXAMPLES: CodeWarrior MCU 10.1 Software Examples.. Size (K): 6832 Format: zip Rev #: 10.1 Modified: 6/7/2011

 

There is a bug in the silicon for all of the kinetis chips. (Errata e2448). All of the example programs I tried with the K60 board I have hang in the PLL_init() function. Whoever ported these from the IAR version forgot to implement this workaround: http://forums.freescale.com/t5/Kinetis-ARM-Cortex-M4/Kinetis-How-to-Work-around-errata-e2448-and-get... I filed a support case. 1-764919891

 

This applied to ANY code running from the FLASH.

 

Here is the work around.    I tested it with 2 of the projects.

 

1.)   Modify the linker command file (for the FLASH(
to add this:
_ROMCodeToCopy = ___ROM_AT + SIZEOF(.app_data); 
.copyToRAM: AT(_ROMCodeToCopy) { 
. = ALIGN (0x4); 
__START_COPYTORAM = .; 
*(CopyToRAM) 
__END_COPYTORAM = .; 
} >> m_data
2.)  You have to add some pragmas around code you want to execute from ram (as code warrior does not support the __ramfunc keyword like IAR).    The set_sys_dividers in the MCG.c file needs to run from ram.
#pragma section CopyToRAM begin
void set_sys_dividers(uint32 outdiv1, uint32 outdiv2, uint32 outdiv3, uint32 outdiv4)
{
..
...
..

}

 #pragma section CopyToRAM end

Outcomes