Interrupt trouble MC9S12DP512

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

Interrupt trouble MC9S12DP512

1,283 Views
paulwilliam
Contributor I

Hi all,

I am have problems with a MC9S12DP512, I am using ICC12 and using TwinPeeks
to load the programs.

My question relates to the operation of the timer interrupts. I can get TC7
working correctly.

But if I try and use TC0 nothing appears to happen. I believe it has
something to do with the redirected interrupt vectors. Mainly because of the
redirect vector that works for TC7 is actually that of TC0 in the manual.

Here is a sample of my code just in case something is incorrect:

// Setup
void SetTimer(unsigned int Ticks){
asm("sei");
TIOS = 0x81;
TIE = 0x81;
TSCR2 = 0x8c;
TC0=Ticks-1;
TC7 = Ticks*2;
TSCR1 = 0x80;
// Clear Timer Flag
TFLG1 = 0x81;
HPRIO = 0xEE;
asm("cli");
}

// ISR for timer 0 this is the same for timer 7
#pragma interrupt_handler Timer0
void Timer0(void){
PTM^=0x01; // Pulse LED
//putstring("abcd\n\r");
// Clear timer interrupt flag
TFLG1 = 0x01;
}

Within the main() function:

//TC7
*((unsigned char *)0x3FE8) = 0x06; // JMP opcode
*((void (**)(void))0x3FE9) = Timer7;

// TC0
*((unsigned char *)0x3FFD) = 0x06; // JMP opcode
*((void (**)(void))0x3FFE) = Timer0;

SetTimer(200);

while(1){

}

Any help would be greatly appreciated

Paul

 

 

 

 

 

 

Added p/n to subject.



Message Edited by NLFSJ on 2008-02-19 07:08 AM
Labels (1)
0 Kudos
1 Reply

259 Views
admin
Specialist II
Hello,
i have not checked your program, but
i think you use the wrong addresses. Here are
the vectors for the 9s12D64 that i use.
Eggert

*((unsigned char *)0x3fd3) = 0x06;
*((void (**)(void))0x3fd4) =TC7handler;    

*((unsigned char *)0x3fd6) = 0x06;
*((void (**)(void))0x3fd7) =TC6handler;    

*((unsigned char *)0x3fd9) = 0x06;
*((void (**)(void))0x3fda) =TC5handler;    

*((unsigned char *)0x3fdc) = 0x06;
*((void (**)(void))0x3fde) =TC4handler;    

*((unsigned char *)0x3fdf) = 0x06;
*((void (**)(void))0x3fe0) =TC3handler;    

*((unsigned char *)0x3fe2) = 0x06;
*((void (**)(void))0x3fe3) =TC2handler;    

*((unsigned char *)0x3fe5) = 0x06;
*((void (**)(void))0x3fe6) =TC1handler;    

*((unsigned char *)0x3fe8) = 0x06;
*((void (**)(void))0x3fe9) =TC0handler;    
*/
0 Kudos