Note that the abs_address at the start of the vector array has to be
calculated so that the reset vector lies at 0xFFFE. If you have a
bootloader inside the protected block where the real vector table
resides, then it should take on the responsibility of building a pseudo
jump table from real values sent during download (as is the case in my
example). If not then the programmer will have to know exactly where
the bootloader expects to see the pseudo table and hardcode the vector
array to that location.
Note too the nonpaged_function pragma. Here it isn't required because
the C32 can fit all code into a linear space, however in your case you
are probably doing a banked build and will need to use it.
-rob
Paul Williams wrote: > Hi,
>
> 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;//0x88;
> TC0=Ticks-1;
> TC7 = Ticks - 1;
> TSCR1 = 0x80;
> // Clear Timer Flag
> TFLG1 = 0x81;
> // Make the timer 7 the highest priority interrupt
> 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;
>
> Any help would be greatly appreciated
>
> Paul
>
>
Reply by Rob Milne●February 19, 20082008-02-19
Hi Paul,
I haven't slavishly checked your register settings so maybe that is part
of your problem. I didn't see the TSCR1 reg with TEN bit set.
In ICC the easiest way to setup the isr vectors is via a vector file
with the following example for a c32:
Note that the abs_address at the start of the vector array has to be
calculated so that the reset vector lies at 0xFFFE. If you have a
bootloader inside the protected block where the real vector table
resides, then it should take on the responsibility of building a pseudo
jump table from real values sent during download (as is the case in my
example). If not then the programmer will have to know exactly where
the bootloader expects to see the pseudo table and hardcode the vector
array to that location.
Note too the nonpaged_function pragma. Here it isn't required because
the C32 can fit all code into a linear space, however in your case you
are probably doing a banked build and will need to use it.
-rob
Paul Williams wrote: > Hi,
>
> 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;//0x88;
> TC0=Ticks-1;
> TC7 = Ticks - 1;
> TSCR1 = 0x80;
> // Clear Timer Flag
> TFLG1 = 0x81;
> // Make the timer 7 the highest priority interrupt
> 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;
>
> Any help would be greatly appreciated
>
> Paul
>
>
Reply by Paul Williams●February 19, 20082008-02-19
Hi,
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;//0x88;
TC0=Ticks-1;
TC7 = Ticks - 1;
TSCR1 = 0x80;
// Clear Timer Flag
TFLG1 = 0x81;
// Make the timer 7 the highest priority interrupt
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;
}