Simplified -- How to Work around errata e2448 -- Part 2 Clock Code in RAM

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

Simplified -- How to Work around errata e2448 -- Part 2 Clock Code in RAM

776 Views
eli_hughes
Contributor V

This is a follow up to some other posts about getting around errate e2448 (which should be posted everywhere and is extremely nasty!!)

 

about 9 months I got a solution from support that I posted that never really worked right.

 

I have a much simpler solution now.  See Attached.

 

**************************

A two step solution

**************************

 

 

1.)      At the *(.relocate_code) to the linker command file in the .app_data section right after *(.data).   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.

 

 .app_data: AT(___ROM_AT)

{

      * (.sdata)

      * (.data)

      *(.relocate_code) <<<<<<<<

            .= ALIGN(0x4) ;

      *(.ARM.extab)

1.)                .= ALIGN(0x4) ;

 

 

2.) A couple useful Macros:

 

#pragma define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX

#define __relocate_code__   __declspec(relocate_code)

 

3.)Use the __relocate_code__ macro infront the function delclarations

 

_relocate_code__ void InitClock()

{

// If the internal load capacitors are being used, they should be selected

// before enabling the oscillator. Application specific. 16pF and 8pF selected

// in this example

  OSC_CR = OSC_CR_SC16P_MASK | OSC_CR_SC8P_MASK;

// Enabling the oscillator for 8 MHz crystal

// RANGE=1, should be set to match the frequency of the crystal being used

// HGO=1, high gain is selected, provid

 

..

..

.

 

 

4.)  Compile for FLASH and check the linker map.  You will notice that there is a function of size 0xF2 in the .App_data section:

# .app_data

  1FFF8000 0000000F .data   @67     (main.obj)

  1FFF800F 00000001 .data   @400    (libc_Thumb_LE_v7M.a printformat_.o )

  1FFF8010 000000F2 .relocate_code InitClock    (Clock.obj)

 

 

I just tested this with the K40 tower board.

 

 

**************************

One less step

**************************

 

 

Also note that you should be able to change the

 

 

#pragma define_section relocate_code ".relocate_code" ".relocate_code" ".relocate_code" far_abs RX

 

 To

 

#pragma define_section relocate_code ".data" ".data" ".data" far_abs RX

 

And not have to change the linker file.   This makes it possible to relocate code without a special linker file.

 

 

 

 

-Eli

0 Kudos
0 Replies