MC9S12C32 Output Compare interrupt works in CodeWarrior debug mode not NanoCore12 run mode.

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

MC9S12C32 Output Compare interrupt works in CodeWarrior debug mode not NanoCore12 run mode.

2,697 Views
bhansen
Contributor I

I am using CodeWarrior with a MC9S12C32 in a Technological Arts NanoCore12 board.  The problem I am having is with output compare interrupt.

When I run a program from CodeWarrior Debug->(F5) using HCS12_Serial_Monitor the program and interrupt operates correctly.

When I run the program in the NanoCore12 boards run mode the interrupt routine does not function but the remaining code does functions correctly.  Any suggestions.

Labels (1)
0 Kudos
Reply
4 Replies

651 Views
bhansen
Contributor I
The interrupt routine is a milli second timer.  I monitor this time to perform various tasks, lets say output a pin.  Works fine using CW debug, not when run from NanoCore run mode.
 
void setup_int(void){
      /* set up timer 7 modulus compare up counter interrupt routine*/
   DisableInterrupts;
    TC7 = 375;       /* load compare count (time_delay) timer 7*/
    TIE = 0b10000000;     /* enable interrupt for timer 7*/
    TSCR1 = 0b10000000;  /* starts main timer TCNT with manual compare match flag rest*/
    TSCR2= 0b00001110;   /* select TC7 reload to TCNT on compare equal with 64 prescaler*/
    TIOS |= 0b10000000;   /* enable timer 7 for output compare*/
   mscount=0;
  EnableInterrupts;
}
/* interrupt routine for timer 7 interrupt 15 */
 
interrupt 15 void ms_count(void){
  
    mscount++;     /* inc timer by 1 */
    TFLG1 |= 0b10000000;  /* clear timer 7 interrupt flag*/
    TFLG2 |= 0b10000000;  /* clear TOF flag of TCNT*/
}
0 Kudos
Reply

651 Views
kef
Specialist I
Looks good, except two things;
 
1) TFLG1 |= 0b10000000; may have side effects. It will clear not only TC7 flasg, but also other TFLG1 flags.
 
Use TFLG1 = 0b10000000;
 
Above doesn't break your current code, but please keep that in mind.
 
 
2) As far as I know, serial monitor occupies and write protects 2kB of flash, including regular vector table at FF80-FFFF. I wonder how your code could work with serial monitor since you have
 
interrupt 15 void ms_count(void){
 
15 is good for TC7 vector in normal vector table at FF80-FFFF. Having serial monitor installed, you should use secondary vector table at F780-F7FF. You should replace 15 with (15+1024). 1024 is the size of serial monitor divided by sizeof(vector entry)==2.
 
You also should fix prm file you are currently using. It should have
 
VECTOR 1024 _Startup
 
instead of
 
VECTOR 0 _Startup


Message Edited by kef on 2008-01-22 10:19 AM
0 Kudos
Reply

651 Views
bhansen
Contributor I

The original vector address for timer 7 compare is 0xFFE0 the address with monitor installed is 0xF7E0 (the 2048 you spoke about).  If I look at memory address 0xF7E0 it equals 0xC166, which is the actual starting location of the interrupt 15 routine.  I am assuming that these values are actually burned in these addresses and not simulated by the debugger.

I put PTT ^= 0x01 inside the interrupt routine and pin 1 toggles when run from the CodeWarrior debug.  If I run the same code using run mode on NanoCore12, pin 1 stays high and does not toggle.  Its acting like the interrupt is disabled or not being reset, I told your suggestion on resetting the flag.  I can’t explain it.

I ordered a P&E Multilink last night, I am going to try it without the monitor.  I am going that direction sooner or later.

Thanks for all your help.

0 Kudos
Reply

651 Views
kef
Specialist I
Are you trying to reset TCNT register to zero by writing it? It's possible only in special modes.
Also it could by some write once register. You may write it once per MCU reset in normal mode, but write many times in special modes.
0 Kudos
Reply