Gcc and the RTI intterupt on a 9s12, weirdness

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Gcc and the RTI intterupt on a 9s12, weirdness

跳至解决方案
1,710 次查看
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
}

标签 (1)
0 项奖励
回复
1 解答
1,087 次查看
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 项奖励
回复
1 回复
1,088 次查看
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 项奖励
回复