Gcc and the RTI intterupt on a 9s12, weirdness

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

Gcc and the RTI intterupt on a 9s12, weirdness

Jump to solution
1,082 Views
Vasilakes
Contributor II

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
}

Labels (1)
0 Kudos
1 Solution
459 Views
Vasilakes
Contributor II

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

View solution in original post

0 Kudos
1 Reply
460 Views
Vasilakes
Contributor II

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

0 Kudos