OK, so I am trying to get the Real time interrupt to work on the 9s12.
I am using a 9s12, and the gnu c compiler.
I am compiling as C++
I have a simple app, no debugger unfortuneately.
I have the serial port working so I can write data out.
I have a while loop in main that waits for some time to elapse, then will print a message out the serial port.
The RTI interrupt just increments a variable once every 1.024ms
Yes RTI clears the interrupt flag.
The timeout never happens...unless
I print to the serial port before the part where I check for timeout.
The serial port uses interrupts and works fine
So what the heck am I doing wrong?
This should work right?
( not all the code, just the impotant parts )
volatile UINT16 TimerTic; void main(void) { RTICTL = 0x10; // Timer counts at 1.024 ms / tic CRGINT_RTIE = 1; // enable interrupt CRGFLG_RTIF = 1; // clear interrupt flag (0 writes have no effect) ... EnableInterrupts; UINT16 starttime = TimerTic; for(;;) { //without this line TimerTic never seems to increment Putstr("Why do I need this?\r\n"); if(TimerTic - starttime > 1000) //wait 1 second { PutStr("hello\r\n"); starttime = TimerTic; } } // 1.024 ms clock interrupt - clear flag immediately to resume count void Timer_Tick_ISR(void) __attribute__((interrupt)) { CRGFLG_RTIF = 1; //CRGFLG = 0x80; // clear RTI interrupt flag TimerTic++; // 1.024 ms, Clock tic }
Solved! Go to Solution.
OK I found the issue with help from the GNU 68hd11 group.
The serial tx empty interrupt was not being disabled after the buffer was empty so it stole all the processor time.
Disable the interrupt properly and it works.
Keith
OK I found the issue with help from the GNU 68hd11 group.
The serial tx empty interrupt was not being disabled after the buffer was empty so it stole all the processor time.
Disable the interrupt properly and it works.
Keith