sprintf interaction with timer interrupt

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

sprintf interaction with timer interrupt

1,424 Views
mikey1
Contributor III
for the 9S12X chip I am getting the wrong results from the sprintf function if I am running in Large memory model and have a timer interrupt running.  It apears that the GPAGE register is not preserved correctly and the sprintf code fails to do its thing correctly.  Some times the code even locks up and does not return. the code runs in banked memory model without a hitch.  Do I have something set up wrong for the Large memory model?
Labels (1)
0 Kudos
2 Replies

342 Views
mikey1
Contributor III
Thanks for the advice!  I tried it out and it worked great.  Now is my time for complaining.  If an interrupt routine is going to disturb a page register why should we have to tell it to resotre the register when done?  I thought that would be the most logical thing to do!!!!
0 Kudos

342 Views
CrasyCat
Specialist III
Hello
 
You need to tell the compiler it needs to save the GPAGE in the interrupt function entry code and restore it at in the exit code.
 
In order to make sure the GPAGE is preserved over an interrupt you can:
  1- Use pragma TRAP_PROC SAVE_ALL_REGS
      Drawback here is the compiler will save all page registers (PPAGE, GPAGE, RPAGE, EPAGE).
      This might be too much overhead for the interrupt function
  2- Build with option -CpGPAGE=0x10
      An interrupt routine saves, by default, those page registers given by the line options "-Cp".
 
I hope this helps
 
CrasyCat
0 Kudos