RTI deadlock and stack overflow

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

RTI deadlock and stack overflow

Jump to solution
2,346 Views
Evgenij
Contributor III

Hi everybody, need help or advice.

Work with mc68hc912bc32 in Code Warrior ver. 5.5 without Processor Expert using C.

Have a problem - when RTI called my program become to a cycle in RTI procedure and never return to main procedure (but other interrupts work for some time). It seems like return vector rewrites to RTI procedure but not to last operation in main procedure in moment of RTI called. So RTI procedure becames as main and gets cycle in it all time. For some time of such working microcontroller's stack overflow! (in C! not assembler). All other interrupts work correctly, when I use assembler all is ok too. That's problem?

I've wrote little demonstration project, that also have this problem and put it here. Can you look to it? May be there is some error in initialization of RTI or some header file forget?

Thank you. If any questions ask me.

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
694 Views
Evgenij
Contributor III
Oh, I'm really sorry. I've need to read manuals more carrefully and attentively. All is OK now.
Sorry, thank you.

View solution in original post

0 Kudos
5 Replies
694 Views
kef
Specialist I
When you are "using assembler", do you clear interrupt flags? Because none of your ISRs are clearing interrupt flags. SCI ISR also doesn't fill TX buffer while you have TIE enabled.
Also, I don't see how you could get stack overflow. Do you have stack so small, so that it overflows in single printf("LED 1 changed..\n"); call? Ughh
0 Kudos
694 Views
Evgenij
Contributor III
Hm, sorry. I've watched my assembler and get sure, that it doesn't work too.
So, why stack overflow I know now - the interrupt procedure become recursive many times, I think so.
For clearing interrupt flags I guess too. But what I've done with RTI it does not work. As I think I've clear RTIF (1 = Set when the time-out period is met) in RTIFLG.
So at the end of RTI procedure I write:
  RTIFLG = 0;
But it also doesn't work and value of RTIFLG register stays 0x80 at memory map in simulation. Is it not writable? I think it is read and write anytime. Other interrupts work correctly as for my eyes.
Can you complement my procedure for full and right?
 
uchar c;
 c_rti ++;
 if (c_rti == 8) {
  c_rti = 0;
  c = PORTB;
  c = !(PORTB & 1);
  PORTB = c;
  printf("LED 1 changed..\n");
 }
RTIFLG = 0;                  //I have no effect
 
Thank you.
0 Kudos
694 Views
kef
Specialist I


Evgenij wrote:
So, why stack overflow I know now - the interrupt procedure become recursive many times, I think so.
 
Wrong assumption. I advice you to read CPU12 reference manual.
 
For clearing interrupt flags I guess too. But what I've done with RTI it does not work. As I think I've clear RTIF (1 = Set when the time-out period is met) in RTIFLG.
So at the end of RTI procedure I write:
  RTIFLG = 0;
And it does nothing.
 
But it also doesn't work and value of RTIFLG register stays 0x80 at memory map in simulation. Is it not writable? I think it is read and write anytime. Other interrupts work correctly as for my eyes.
 
Have you ever opened HC12B family datasheet?
 
Can you complement my procedure for full and right?
Yes I can, but I won't. Use forum search at bottom of this page and you'll find RTI examples. Also CW examples may contain examples with interrupts handling. Good luck
 
0 Kudos
695 Views
Evgenij
Contributor III
Oh, I'm really sorry. I've need to read manuals more carrefully and attentively. All is OK now.
Sorry, thank you.
0 Kudos
694 Views
Evgenij
Contributor III
Ok, thanks. I'll try to find examples on forum and read reference once more.
Motorola controllers are new for me, but I have hard terms for this work.
I worked more with x51 family and my CW was only with pair of examples.
Good luck.
0 Kudos