Coldfire MCF 5208 trap exceptions

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

Coldfire MCF 5208 trap exceptions

6,812 Views
quahogChowda
Contributor I
I am an engineering student doing a project on interrupt handlers and have a question on trap instructions for the Coldfire MCF5208 microcontroller. How do they pass parameters to address and data registers? I have code that I am able to understand except for the trap instructions. It looks like the data registers are being used in coordination with the traps somehow. My resources are very limited. The only classbooks that we have are the technical manuals and they mention nothing of trap functionality. I have included a copy of the code if anyone can add any insight. It is an interrupt handler for counting from 0 to 9 with screen display of the digit. Thanks for any help that anyone can offer.

----

jmp main
pit_handle:
link %A6,#0
move.l %D0,-(%A7)
move.l %D1,-(%A7)
move.l %A0,-(%A7)
movea.l #0x40040000,%A0
move.l (%A0),%D1
move.l #0x13,%d0
trap #15
move.l #0x13,%d0
move.l #13,%D1
trap #15
add.l #1,(%A0)
move.l (%A0),%D0
cmpi.l #0x3A,%D0
blt exit
move.l #0x30,(%A0)

exit: move.l -4(%A6),%D0
move.l -8(%A6),%D1
move.l -12(%A6),%A0
unlk %a6
rts

main:
movea.l #0x80003FF0,%A7
movea.l %A7,%A6

movea.l #0x40040000,%A0
move.l #0x30,(%A0)


movea.l #0xFC080000,%A0
move.l #0x0D1F,%D0
move.W %D0,(%A0)
movea.l #0xFC080002,%A0
move.l #0xFFFF,%D0
move.l %D0,(%A0)

move.l #0x40,%D0
move.l #0x44,%D1
lea pit_handle,%A0
move.l %A0,%D2
move.l #0,%D3
move.l #0,%D4
trap #15

move.l #0xFC048044,%A0
move.l #3,%D0
move.b %D0,(%A0)
move.l #0xFC04800C,%A0
move.l (%A0),%D0
andi.l #0xFFFFFFEF,%D0
move.l %D0,(%A0)


loop:
nop
jmp loop
Labels (1)
0 Kudos
2 Replies

1,567 Views
PBH
NXP Employee
NXP Employee
Hi,
 
Try looking at the ColdFire Programmers Reference (CFPRM.pdf) manual Rev.3 page 3-11 where the interaction of the Trap instructions with registers is described. The CFPRM can be downloaded at - http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=0162468rH3YTLC00M9
 
Under the Reference Manuals section on this page. I hope this helps.
 
 
0 Kudos

1,568 Views
mnorman
NXP Employee
NXP Employee
You should reference the ColdFire Family Programmers Reference Manual (http://www.freescale.com/files/dsp/doc/ref_manual/CFPRM.pdf) for more details on the instruction set including the TRAP instruction.

The register contents will be retained after the TRAP exception is taken. Therefore, any values loaded into the data or address registers will be available to the TRAP interrupt handler. It looks like this code is calling the system call routines in the dBUG ROM monitor that is programmed as the bootable image in most ColdFire evaluation boards. The dBUG system calls are as follows:

_dbug_sc_handler:
lea -12(sp),sp /* room for used regs */
movem.l d2/a0-a1,(sp)
ext.l d0

/* Serial I/O routines */
cmpi.l #0x0010,d0
beq.w _in_char
cmpi.l #0x0013,d0
beq.w _out_char
cmpi.l #0x0014,d0
beq.w _char_present

/* Not a supported system call, jump back to monitor */
movem.l (sp),d2/a0-a1
lea 12(sp),sp
move.l sp,-(sp)
jsr _asm_sc_exit_to_dbug

_in_char:
jsr _board_getchar /* char returned in D0 */
move.l d0,d1
moveq.l #0,d0
bra.w _done

_out_char:
move.l d1,-(sp)
jsr _board_putchar
lea 4(sp),sp
moveq.l #0,d0
bra.w _done

_char_present:
jsr _board_getchar_present /* value returned in D0 */
bra.w _done

_done:
movem.l (sp),d2/a0-a1
lea 12(sp),sp
rte

Message Edited by mnorman on 03-08-200610:55 AM

0 Kudos