A number of things look strange to me.
Read the ICC12 help on the calling sequence stack frame. When you invoke a
C function with a single parameter, that param,eter is already in the D
register. your LDD %func_ptr is redundant. besides, the name reference for
the asm equivalent of a C name is the name preceeded by an underscore. i.e.
_func_ptr .
I will assume that you properly used the debug12 function to install the
interrupt vector, and that somewhere you properly declared count.
In ICC12, when you use #pragma interrupt_handler, thr rti return is
automatically coded. you do not have to add it with an asm statement.
You did not show any code to initialize and enable the timer, and rti
interrupt. without this, the timer interrupt will never be called.
At 03:40 PM 3/3/2004, you wrote:
>Thanks for replying so quickly!
>
>We are using a hcs12dp256 Motorolla Microcontroller. The purpose of
>our robot is to navigate a game board (the game board of the Trinity
>Firefighting robot competition) and retrieve an object. We want our
>servo motors to run for a specific time and stop either because the
>time came up or because an IR sensors says a wall is in the way or
>something.
>
>/* 520 */ void setISR ( void ( * func_ptr ) ( void ) )
>/* 521 */ {
>/* 522 */ asm("LDD %func_ptr") ;
>/* 524 */ asm("PSHD") ;
>/* 525 */ asm("CLRA") ;
>/* 526 */ asm("LDAB # 56") ;
>/* 527 */ asm("LDX 0xEEA4") ;
>/* 528 */ asm("JSR 0 , X") ;
>/* 529 */ asm("PULD") ;
>/* 530 */
>/* 531 */ }
>
>RTICTL = 0x0014;
>CRGFLG = 0x80;
>
>DBug12FNP->SetUserVector(56, (char *)Timer);
>printf("Loc: %x -- %p\n", Timer, _ADDR(0x3e70));
>#pragma interrupt_handler Timer
>void Timer()
>{
> count++;
> CRGFLG = 0x80;
> asm("rti");
>}
>
>OK, there is some of the code we are trying to use. The first chunk
>was a test with some assembly we saw that supposedly got the
>interrupts working (or something that we could test). ICC12 has the
>feature of writing assuembly right into the program, which is cool,
>but it didn't really work for us.
>
>The second section of code is where we try to set the timer and real
>time interrupt (rti) with allocated vectors and such. It actually
>spits out the output shown and is what we set it up to be, but then
>nothing works in the last section of code.
>
>We wanted the loop to just use our interrupt handle to stop the
>program (interrupt it), increase the number, and move on, but when
>we run it, the output just stays at zero.
>
>Thanks again for your help. If seeing the interrupt_handle function
>would be helpful, I can post that guy too!
>
>Later.
>
>Clay
>
>
>--------------------To learn more
>about Motorola Microcontrollers, please visit
>http://www.motorola.com/mcu
>o learn more about Motorola Microcontrollers, please visit
>http://www.motorola.com/mcu
>
>Yahoo! Groups Links
>
>
|