Скачиваний:
38
Добавлен:
27.04.2015
Размер:
3.97 Mб
Скачать

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

A.2 Bootstrap Listing

The bootstrap program listing is shown in Example A-1.

Example A-1. DSP56824 Bootstrap Code

;**************************************************************************

;* boot_56824.asm

;*

;* Bootstrap source code for the Motorola DSP56824.

;* (C) Copyright 1999 Motorola Inc.

;*

;* This is the source code for the bootstrap program contained in the 56824.

;* This program is executed on hardware reset in Mode 1. The program can load

;* the internal program memory from one of two external sources. The

;* program reads P:$C000 to decide which external source to access.

;* The sources include:

;*

;* - Bootstrapping from external byte-wide memory (lower byte of data bus)

;* - Bootstrapping through the SPI serial port (SPI0)

;*

;* The decision for which port is selected is shown here:

;* if (bit 15 of P:$C000 == 0)

;* load program RAM through the SPI (SPI0)

;* if (bit 15 of P:$C000 == 1)

;* load program RAM from consecutive byte-wide P: memory locations

;* (typically EPROM), starting at P:$C000 (lower byte of data bus)

;*

;* The number of words to load and the starting load address:

;* The first 2 bytes read from external memory or the SPI

;* indicate the number of program words which will

;* be loaded. The next 2 bytes indicate the starting load

;* address; the boot loader will also jump to this address

;* after all of the words have been loaded. Usually the load

;* address is 0 (internal PRAM), but the user has the option

;* to load external program ram if desired. Also, note that both of

;* these parameters should be passed least-significant-byte first:

;*

;* <1st byte read> lower byte of number of words to be loaded

;* <2nd byte read> upper byte of number of words to be loaded

;* <3rd byte read> lower byte of load address

;* <4th byte read> upper byte of load address

;* Loading PRAM from external byte-wide memory:

;* The boot ROM code will load bytes from the external P memory

;* space beginning at P:$C004 (bits 7-0). Each two bytes will be condensed

;* into a 16-bit word and stored in contiguous internal PRAM memory

;* locations. Note that routine loads data starting with the least

;* significant byte:

A-4 DSP56824 User’s Manual

For More Information On This Product,

Go to: www.freescale.com

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Example A-1. DSP56824 Bootstrap Code (Continued)

; *

P:$C000

lower byte

of

number of words to be loaded

; *

P:$C001

upper byte

of

number of words to be loaded

; *

P:$C002

lower byte

of

load address

; *

P:$C003

upper byte

of

load address

; *

P:$C004

lower byte

of

first word to be loaded

; *

P:$C005

upper byte

of

first word to be loaded

; *

P:$C006

lower byte

of

second word to be loaded

; *

P:$C007

upper byte

of

second word to be loaded

; *

.

and so on.

;*

;* Loading PRAM from the SPI port

;* The boot ROM code loads the internal pram from the SPI port.

;* Each two bytes will be condensed into a 16-bit word and stored in

;* contiguous PRAM memory locations. Note that when using the SPI,

;* the routine loads data starting with the least significant byte

;* first. For the SPI, the maximum frequency allowed on the serial

;* clock pin is 10 MHz.

;*

;* NOTE:

;* If this program is entered in software by jumping to p:$7f80,

;* make certain that the M01 register has been set to $FFFF (linear

;* addressing). In addition, make sure the BCR register is set to $xxxF

;* to support slow external EPROMs for the bootstrapping operation.

;* Also, make sure the MB:MA bits in the OMR register are set to Mode 1.

;*

;* Registers used by the program:

;* R0 - pointer used to write 16-bit instructions to on-chip PRAM

;* R1 - points to load/jump address

;* R2 - pointer used to read 8-bit data from off-chip P memory when

;* bootstrapping through the External Bus

;* Y0 - contents of P:$C000, used to save MSB which selects SPI vs. EXT BUS

;

*

A

-

loop counter

;

*

B

-

register which holds an 8-bit sample from one of the 2 ports

;* SP - used for the jump to the load address. SP=$3F after exiting

;* the boot loader.

;*

;* Memory used by the program:

;* X:$40 and X:$41 are used by the stack

;*

;**************************************************************************

;*

page

255

 

 

opt

cc,now,mu

 

BOOT

EQU

$C000

; The location in P: memory where the external

 

 

 

; byte-wide EPROM is located when loading from

 

 

 

; Port A. Also, the MSB of the value read at

 

 

 

; this location is used to select SPI vs. EXT BUS

PCC

EQU

$FFED

; Port C control register

SPCR0

EQU

$FFE2

; SPI0 control register

SPSR0

EQU

$FFE1

; SPI0 status register

SPSR0

EQU

$FFE1

; SPI0 status register

Bootstrap Program A-5

For More Information On This Product,

Go to: www.freescale.com

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Example A-1. DSP56824 Bootstrap Code (Continued)

;***

;*** Initial entry into the bootstrap program:

;*** - Initialize R2 to address of external byte-wide ROM ($C000)

;*** - read the contents of P:$C000 (external memory)

;*** - if bit 15 is one, bypass SPI initialization

;***

ORG

P:$7F80

; Mode 1 reset vector

nop

; Two NOPs to account for the case when

nop

; COP reset occurs and transfers control

 

; to the COP reset vector at P:$7F82

move

#$3f,sp

; Initialize the stack pointer

 

 

;

above page 0

MOVE

#BOOT,R2

; Setup R2 as P: address of

clr

a

; external byte-wide ROM

 

 

movem

a,p:(r2)+

; Handle case where there’s

lea

(r2)-

;

SRAM at P:$C000

MOVE

P:(R2)+,Y0

; Get P:$C000

LEA

(R2)-

; Adjust pointer, because in the case

 

 

; where bootstrapping from external

 

 

; P memory, P:$C000 will be read again

BRSET

#$8000,Y0,_BYPASS_SPI

; if (P:$C000’s MSB == 1)

 

 

;

bypass SPI

 

 

; else

 

 

;

initialize SPI

; ****************** Initialize the SPI if necessary *************

_INIT_SPI

 

 

 

BFSET

#$0004,X:SPCR0

; Set up SPIO’s SPCR control register:

 

 

;

- interrupts disabled

 

 

;

- Wired-OR mode disabled

 

 

;

- Slave mode

 

 

;

- CPL set to 0

 

 

;

- CPH set to 1

 

 

;

- SPR2-0 not used since Slave mode

BFSET

#$0040,X:SPCR0

; Enable SPI via setting SPE bit

BFSET

#$000F,X:PCC

; Set PC0-PC3 to MISO0,MOSI0,SCK0,SS0

; ****************** End of SPI initialization *************

_BYPASS_SPI

; *** Determine the number of words to be loaded*************

jsr

get_word

 

; received word is now in b0

 

move

b0,a

; put number of words in a

;***********************************************************

;******************** Determine the load address*************

jsr

get_word

 

; received word is now in b0

 

move

b0,r0

; put in r0

move

b0,r1

; and save in r1 for jmp

; ***********************************************************

tstw

a

 

beq

_exit

; if 0 words are to be loaded

 

 

; branch to _exit

A-6 DSP56824 User’s Manual

For More Information On This Product,

Go to: www.freescale.com

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Example A-1. DSP56824 Bootstrap Code (Continued)

; ***************** Main Loop **************************

_main_loop

jsr

get_word

 

move

b0,b

 

move

b,p:(r0)+

; put word into PRAM

decw

a

; decrement number of words counter

bgt

_main_loop

 

;********************* End of Main Loop *********************

;***

;*** Exit bootstrap program

;*** - goto P:(r1)

;***

_exit

; goto to r1 by pushing it onto the stack and issuing an rts

lea

(sp)+

 

move

r1,x:(sp)+

 

ANDC

#$FF00,SR

; clear SR as if HW reset

move

sr,x:(sp)

 

rts

 

 

; ******* Shared subroutine to pack 2 bytes read into a word *******

get_word

 

 

do

#2,end_get_word

 

brset

#$8000,y0,_read_from_ext_mem

_read_from_spi

 

 

BRCLR

#$0080,X:SPSR0,*

; - Wait for SPIF flag to go high

MOVE

X:SPSR0,B1

; Read of SPSR0 used to clear SPIF flag

MOVE

X:SPDR0,B1

; Put SPI’s byte into lower byte of B1

bra

_pack_pram

 

_read_from_ext_mem

 

 

move

p:(r2)+,b1

; put external mem into low bype of B1

_pack_pram

 

 

rep

#8

 

asr

B

; shift into B0

nop

 

 

end_get_word

 

 

rts

; ***************** End of subroutine ********************************

END

Bootstrap Program A-7

For More Information On This Product,

Go to: www.freescale.com

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Freescale Semiconductor, Inc.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

A-8 DSP56824 User’s Manual

For More Information On This Product,

Go to: www.freescale.com

Соседние файлы в папке DSP568xx