Datasheet

Chapter 4. Local Memory 4-5
SRAM Initialization
2. Read the source data and write it to the SRAM. Various instructions support this
function, including memory-to-memory move instructions and the move multiple
instruction (MOVEM). MOVEM is optimized to generate line-sized burst fetches on
line-aligned addresses, so it generally provides maximum performance.
3. After the data is loaded into the SRAM, it may be appropriate to revise the
RAMBAR attribute bits, including the write-protect and address space mask elds.
If the SRAM contains instructions, RAMBAR[D/I] must be set to logically connect
the memory to the processor’s internal instruction bus.
Remember that the SRAM cannot be accessed by the on-chip DMAs. The on-chip system
conguration allows concurrent core and DMA execution where the core can execute code
out of internal SRAM or cache during DMA access.
The ColdFire processor or an external emulator using the debug module can perform these
initialization functions.
4.5.1 SRAM Initialization Code
The code segment below initializes the SRAM using RAMBAR0. The code sets the base
address of the SRAM at 0x2000_0000 and then initializes the RAM to zeros.
RAMBASE EQU 0x20000000 ;set this variable to 0x20000000
RAMVALID EQU 0x00000035
move.l #RAMBASE+RAMVALID,D0 ;load RAMBASE + valid bit into D0
movec.l D0, RAMBAR0 ;load RAMBAR0 and enable SRAM
The following loop initializes the entire SRAM to zero:
lea.l RAMBASE,A0 ;load pointer to SRAM
move.l #512,D0 ;load loop counter into D0
SRAM_INIT_LOOP:
clr.l (A0)+ ;clear 4 bytes of SRAM
subq.l #1,D0 ;decrement loop counter
bne.b SRAM_INIT_LOOP ;exit if done; else continue looping
The following function copies the number of bytesToMove from the source (*src) to the
processor’s local RAM at an offset relative to the SRAM base address dened by
destinationOffset. The bytesToMove must be a multiple of 16. For best performance, source
and destination SRAM addresses should be line-aligned (0-modulo-16).
; copyToCpuRam (*src, destinationOffset, bytesToMove)
RAMBASE EQU 0x20000000 ;SRAM base address
RAMFLAGS EQU 0x00000035 ;RAMBAR valid + mask bits
lea.l -12(a7),a7 ;allocate temporary space
movem.l #0x1c,(a7) ;store D2/D3/D4 registers
; stack arguments and locations