<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Simplified -- How to Work around errata e2448 -- Part 2  Clock Code in RAM in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Simplified-How-to-Work-around-errata-e2448-Part-2-Clock-Code-in/m-p/178211#M1599</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a follow up to some other posts about getting around errate e2448 (which should be posted everywhere and is extremely nasty!!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;about 9 months I got a solution from support that I posted that never really worked right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a much simpler solution now.&amp;nbsp; See Attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;A two step solution&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;At the *(.relocate_code) to the linker command file in the .app_data section right after *(.data).&amp;nbsp;&amp;nbsp; This will allow one to locate functions in the initialized data section (i.e. at startup stuff in this area is copied from init values in the flash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;.app_data: &lt;STRONG&gt;AT&lt;/STRONG&gt;(___ROM_AT)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; * (.sdata)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; * (.data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;STRONG&gt;*(.relocate_code) &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .= &lt;STRONG&gt;ALIGN&lt;/STRONG&gt;(0x4) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; *(.ARM.extab)&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .= &lt;STRONG&gt;ALIGN&lt;/STRONG&gt;(0x4) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) A couple useful Macros:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#define&lt;/STRONG&gt; __relocate_code__&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;__declspec&lt;/STRONG&gt;(relocate_code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.)Use the __relocate_code__ macro infront the function delclarations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_relocate_code__ &lt;STRONG&gt;void&lt;/STRONG&gt; &lt;STRONG&gt;InitClock&lt;/STRONG&gt;()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;// If the internal load capacitors are being used, they should be selected&lt;/P&gt;&lt;P&gt;// before enabling the oscillator. Application specific. 16pF and 8pF selected&lt;/P&gt;&lt;P&gt;// in this example&lt;/P&gt;&lt;P&gt;&amp;nbsp; OSC_CR = OSC_CR_SC16P_MASK | OSC_CR_SC8P_MASK;&lt;/P&gt;&lt;P&gt;// Enabling the oscillator for 8 MHz crystal&lt;/P&gt;&lt;P&gt;// RANGE=1, should be set to match the frequency of the crystal being used&lt;/P&gt;&lt;P&gt;// HGO=1, high gain is selected, provid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4.)&amp;nbsp; Compile for FLASH and check the linker map.&amp;nbsp; You will notice that there is a function of size 0xF2 in the .App_data section:&lt;/P&gt;&lt;P&gt;# .app_data&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF8000 0000000F .data&amp;nbsp;&amp;nbsp; @67&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (main.obj)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF800F 00000001 .data&amp;nbsp;&amp;nbsp; @400&amp;nbsp;&amp;nbsp;&amp;nbsp; (libc_Thumb_LE_v7M.a printformat_.o )&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF8010 000000F2 .relocate_code InitClock&amp;nbsp;&amp;nbsp;&amp;nbsp; (Clock.obj)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tested this with the K40 tower board.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;One less step&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also note that you should be able to change the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".data" ".data" ".data" far_abs RX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And not have to change the linker file.&amp;nbsp;&amp;nbsp; This makes it possible to relocate code without a special linker file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 30 Oct 2011 08:44:46 GMT</pubDate>
    <dc:creator>eli_hughes</dc:creator>
    <dc:date>2011-10-30T08:44:46Z</dc:date>
    <item>
      <title>Simplified -- How to Work around errata e2448 -- Part 2  Clock Code in RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Simplified-How-to-Work-around-errata-e2448-Part-2-Clock-Code-in/m-p/178211#M1599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a follow up to some other posts about getting around errate e2448 (which should be posted everywhere and is extremely nasty!!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;about 9 months I got a solution from support that I posted that never really worked right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a much simpler solution now.&amp;nbsp; See Attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;A two step solution&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;At the *(.relocate_code) to the linker command file in the .app_data section right after *(.data).&amp;nbsp;&amp;nbsp; This will allow one to locate functions in the initialized data section (i.e. at startup stuff in this area is copied from init values in the flash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;.app_data: &lt;STRONG&gt;AT&lt;/STRONG&gt;(___ROM_AT)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; * (.sdata)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; * (.data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;STRONG&gt;*(.relocate_code) &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .= &lt;STRONG&gt;ALIGN&lt;/STRONG&gt;(0x4) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; *(.ARM.extab)&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .= &lt;STRONG&gt;ALIGN&lt;/STRONG&gt;(0x4) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) A couple useful Macros:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#define&lt;/STRONG&gt; __relocate_code__&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;__declspec&lt;/STRONG&gt;(relocate_code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.)Use the __relocate_code__ macro infront the function delclarations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_relocate_code__ &lt;STRONG&gt;void&lt;/STRONG&gt; &lt;STRONG&gt;InitClock&lt;/STRONG&gt;()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;// If the internal load capacitors are being used, they should be selected&lt;/P&gt;&lt;P&gt;// before enabling the oscillator. Application specific. 16pF and 8pF selected&lt;/P&gt;&lt;P&gt;// in this example&lt;/P&gt;&lt;P&gt;&amp;nbsp; OSC_CR = OSC_CR_SC16P_MASK | OSC_CR_SC8P_MASK;&lt;/P&gt;&lt;P&gt;// Enabling the oscillator for 8 MHz crystal&lt;/P&gt;&lt;P&gt;// RANGE=1, should be set to match the frequency of the crystal being used&lt;/P&gt;&lt;P&gt;// HGO=1, high gain is selected, provid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4.)&amp;nbsp; Compile for FLASH and check the linker map.&amp;nbsp; You will notice that there is a function of size 0xF2 in the .App_data section:&lt;/P&gt;&lt;P&gt;# .app_data&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF8000 0000000F .data&amp;nbsp;&amp;nbsp; @67&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (main.obj)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF800F 00000001 .data&amp;nbsp;&amp;nbsp; @400&amp;nbsp;&amp;nbsp;&amp;nbsp; (libc_Thumb_LE_v7M.a printformat_.o )&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1FFF8010 000000F2 .relocate_code InitClock&amp;nbsp;&amp;nbsp;&amp;nbsp; (Clock.obj)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tested this with the K40 tower board.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;One less step&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also note that you should be able to change the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section relocate_code ".data" ".data" ".data" far_abs RX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And not have to change the linker file.&amp;nbsp;&amp;nbsp; This makes it possible to relocate code without a special linker file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Oct 2011 08:44:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Simplified-How-to-Work-around-errata-e2448-Part-2-Clock-Code-in/m-p/178211#M1599</guid>
      <dc:creator>eli_hughes</dc:creator>
      <dc:date>2011-10-30T08:44:46Z</dc:date>
    </item>
  </channel>
</rss>

