Dwayne Dietrich

Problem: user code (MCF5208 interrupt) interacting with dBUG

Discussion created by Dwayne Dietrich Employee on Mar 31, 2006
This message contains an entire topic ported from the WildRice - Coldfire forum.  Freescale has received the approval from the WildRice administrator on seeding the Freescale forum with messages.  The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value as you search for answers to your questions.  Freescale assumes no responsibility whatsoever with respect to Posted Material.  For additional information, please see the Terms of Use - Message Boards and Community Forums.  Thank You and Enjoy the Forum!


Jan 4, 2006, 7:22 AM
Post #1 of 2 (41 views)
Copy Shortcut
 [ColdFire] Problem: user code (MCF5208 interrupt) interacting with dBUG  Can't Post 
--------------------------------------------------------------------------------
 
 
I have an M5208EVB board, which has Freescale dBUG in it. The dBUG copy the vector table to 0x40000000. The user code should start from 0x40020000.
I prepared the following code (linked from 0x4002000) trying to use DTMR2 (Timer 2)reference compare interrupt. But I never see interrupt happen (the LEDS did not change). This code is modified from Freescale's sample code for MCF5206e. What is wrong? Need help.
================My Code====================
IMRH EQU 0xFC048008
IMRL EQU 0xFC04800C
ICR34 EQU 0xFC048062 ;TIMER2 interrupt
PAR_TIMER EQU 0xFC0A4035
PDDR_TIMER EQU 0xFC0A4011
PODR_TIMER EQU 0xFC0A4005
TMR2 EQU 0xFC078000 ;Timer2 mode register
TRR2 EQU 0xFC078004 ;Timer2 reference register
TCR2 EQU 0xFC078008 ;Timer2 capture register
TCN2 EQU 0xFC07800C ;Timer2 counter register
TER2 EQU 0xFC078003 ;Timer2 event register

.text
initialization:
;interrupt controller register configuration
move.w #0xfffb,d0 ; initializes IMR register to enable timer2 interrupts
move.w d0,IMRH ; and mask all other interrupt sources
move.b #0x05,d0 ; initializes timer2 ICR for autovectoring and sets
move.b d0,ICR34 ; interrupt level to 5
;general purpose parallel port register configuration
move.b #0x00,d0 ;all timer pins are GPIO
move.b d0,PAR_TIMER
move.b #0xff,d0 ; sets timer port as outputs
move.b d0,PDDR_TIMER ;
move.b #0x02,d0;<----lit one led (comfirmed from running on M5208EVB)
move.b d0,PODR_TIMER
;timer2 register configuration
move.w #0x0f00,d0 ;
move.w d0,TRR2 ; sets timer2 period in TRR2 register.
move.w #0x0000,d0 ;
move.w d0,TCN2 ; clears current timer2 count value.
move.b #0x03,d0 ;
move.b d0,TER2 ; clear timer2 event register
move.l #0x40000000,a6 ; point VBR to start of vector table (0x40000000)
movec a6,VBR
move.l #exceptioncode,d0 ;
move.l d0,VBR+0x188 ; load exception handler code address in vector table
;DTMR2 vector: 0x22*4+0x100=0x188

clr.l d2 ; clear registers d0 & d2
clr.l d0
move.w #0x2400,SR ; enable interrupt level in status register
move.w #0xff3d,d0 ; initializes timer 2 mode register, TMR2, and
move.w d0,TMR2 ; starts timer 2.
m_loop nop
nop
nop
bra m_loop
exceptioncode: ;<----problem, I never see leds change
addi.l #0x1,d2 ;
move.b d2,PODR_TIMER ; increment LEDs
move.b #0x02,d0 ;
move.b d0,TER2 ; clear timer2 event register (TER2)

nop
rte ; return from exception
===================================================
--
View this message in context: http://www.nabble.com/Problem%3A-user-code-%28MCF5208-interrupt%29-interacting-with-dBUG-t849863.html#a2203277
Sent from the Coldfire forum at Nabble.com.
--------------------------------------------------------------------
Jan 7, 2006, 9:32 AM
Post #2 of 2 (36 views)
Copy Shortcut
 Re: [Listserv] [ColdFire] Problem: user code (MCF5208 interrupt) interacting with dBUG [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
The DMA timer registers for the MCF5208 are slightly different than the MCF5206e.
Below is my assembly code version and attached is the "C" code.
Sorry for some extra code. I was playing with two methods CodeWarrior has for interrupt function declaration. I also was blinking LEDs.
Hope this help.
Regards,
David
Assembler main code:
40002438: 4E560000 link a6,#0
4000243C: 598F subq.l #4,a7
4000243E: 4EB940002160 jsr mcf5xxx_irq_disable (0x40002160); 0x40002160
40002444: 4EB9400024F4 jsr int_timer2 (0x400024f4) ; 0x400024f4
4000244A: 4EB94000214C jsr mcf5xxx_irq_enable (0x4000214c); 0x4000214c
40002450: 203CFC078000 move.l #-66617344,d0
40002456: 2040 movea.l d0,a0
40002458: 3210 move.w (a0),d1
4000245A: 7000 moveq #0,d0
4000245C: 3001 move.w d1,d0
4000245E: 008000000001 ori.l #0x1,d0
40002464: 3080 move.w d0,(a0)
40002466: 41F940002CCE lea 0x40002CCE (0x40002cce),a0
4000246C: 2E88 move.l a0,(a7)
4000246E: 4EB9400011A4 jsr printf (0x400011a4) ; 0x400011a4
40002474: 7200 moveq #0,d1
40002476: 13C1FC0A4035 move.b d1,0xFC0A4035 (0xfc0a4035)
4000247C: 700F moveq #15,d0
4000247E: 13C0FC0A4011 move.b d0,0xFC0A4011 (0xfc0a4011)
40002484: 13C1FC0A4005 move.b d1,0xFC0A4005 (0xfc0a4005)
4000248A: 7400 moveq #0,d2
4000248C: 6004 bra.s main+0x56 (0x40002492) ; 0x40002492
4000248E: 4E71 nop
40002490: 5282 addq.l #1,d2
40002492: 0C8200100000 cmpi.l #1048576,d2
40002498: 6DF4 blt.s main+0x56 (0x4000248e) ; 0x4000248e
4000249A: 13C0FC0A4005 move.b d0,0xFC0A4005 (0xfc0a4005)
400024A0: 7400 moveq #0,d2
400024A2: 6004 bra.s main+0x6c (0x400024a8) ; 0x400024a8
400024A4: 4E71 nop
400024A6: 5282 addq.l #1,d2
400024A8: 0C8200100000 cmpi.l #1048576,d2
400024AE: 6DF4 blt.s main+0x6c (0x400024a4) ; 0x400024a4
400024B0: 60D2 bra.s main+0x4c (0x40002484) ; 0x40002484
400024B2: 4E71 nop

Assembler init_timer2() code:
400024F4: 4E560000 link a6,#0
400024F8: 2F07 move.l d7,-(a7)
400024FA: 518F subq.l #8,a7
400024FC: 2E3C00013DC3 move.l #81347,d7
40002502: 41F9400024B4 lea TIMER2_INTERRUPT (0x400024b4),a0
40002508: 2F480004 move.l a0,4(a7)
4000250C: 2EBC00000062 move.l #98,(a7)
40002512: 4EB940002174 jsr mcf5xxx_set_handler (0x40002174); 0x40002174
40002518: 7002 moveq #2,d0
4000251A: 13C0FC078003 move.b d0,0xFC078003 (0xfc078003)
40002520: 23C7FC078004 move.l d7,0xFC078004 (0xfc078004)
40002526: 2039FC07800C move.l 0xFC07800C (0xfc07800c),d0
4000252C: 2F400004 move.l d0,4(a7)
40002530: 41F940002D1C lea 0x40002D1C (0x40002d1c),a0
40002536: 2E88 move.l a0,(a7)
40002538: 4EB9400011A4 jsr printf (0x400011a4) ; 0x400011a4
4000253E: 7003 moveq #3,d0
40002540: 13C0FC048062 move.b d0,0xFC048062 (0xfc048062)
40002546: 70FB moveq #-5,d0
40002548: 23C0FC048008 move.l d0,0xFC048008 (0xfc048008)
4000254E: 303CFF1C move.w #-228,d0
40002552: 33C0FC078000 move.w d0,0xFC078000 (0xfc078000)
40002558: 508F addq.l #8,a7
4000255A: 2E1F move.l (a7)+,d7
4000255C: 4E5E unlk a6
4000255E: 4E75 rts

Assembler TIMER2_INTERRUPT:
400024B4: 4E560000 link a6,#0
400024B8: 4FEFFFE8 lea -24(a7),a7
400024BC: 48EF03070004 movem.l d0-d2/a0-a1,4(a7)
400024C2: 7002 moveq #2,d0
400024C4: 13C0FC078003 move.b d0,0xFC078003 (0xfc078003)
400024CA: 1239FC0A4005 move.b 0xFC0A4005 (0xfc0a4005),d1
400024D0: 7000 moveq #0,d0
400024D2: 1001 move.b d1,d0
400024D4: 4680 not.l d0
400024D6: 13C0FC0A4005 move.b d0,0xFC0A4005 (0xfc0a4005)
400024DC: 41F940002CEE lea 0x40002CEE (0x40002cee),a0
400024E2: 2E88 move.l a0,(a7)
400024E4: 4EB9400011A4 jsr printf (0x400011a4) ; 0x400011a4
400024EA: 4CEF03070004 movem.l 4(a7),d0-d2/a0-a1
400024F0: 4E5E unlk a6
400024F2: 4E73 rte 
 
 

Message Edited by Dietrich on 04-01-2006 11:42 AM

Message Edited by Dietrich on 04-04-2006 01:46 PM

Outcomes