Hello,
Maybe someone here can help me.
I was writing software and everything was working, untill at one point all my interrupts quit working.
I was using full PE emulator to check my timer count minutes hours etc. But now it will never hit the ISR???
/*****************************************************************************
MC9S08JM60
Program Function:
*****************************************************************************/
#include <hidef.h> //for EnableInterrupts macro
#include <MC9S08JM60.h> //include peripheral declarations
#include "LEDDEF.h" //include external file with declarations and definitions
/*define led's*/
#define LED1 PTED_PTED2 //Port E 2 (LED1)
#define LED2 PTED_PTED3 //Port E 3 (LED2)
#define LED3 PTFD_PTFD0 //Port F 0 (LED3)
#define LED4 PTFD_PTFD1 //Port F 1 (LED4)
#define BUZ1 PTFD_PTFD4 //Port F 4 (BUZZER)
/*define switches*/
#define BTH10 PTGD_PTGD0 //Port G 0 (Hour 10s Button)
#define BTH1 PTGD_PTGD1 //Port G 1 (Hour 1s Button)
#define BTM10 PTGD_PTGD2 //Port G 2 (Minute 10s Button)
#define BTM1 PTGD_PTGD3 //Port G 3 (Minute 1s Button)
int i=0,H10=1,H1=1,M10=0,M1=6,S10=0,S1=0;
//*** Timer Interrupt ISR - 100ms
interrupt 15 void intTPM1OVF(){
byte count=10;
count--;
if(!count){ //if count is 0 then 1 second passed
count=10;
S1++;
if(S1>9){
S10++;
S1=0;
if(S10>5){
M1++;
S10=0;
if(M1>9){
M10++;
M1=0;
if(M10>5){
H1++;
M10=0;
if(H10>2){
H10=0;
}
}
}
}
}
}
TPM1SC_TOF = 0; //reset timer overflow flag
}
/******************************MAIN********************************/
void main(void) {
//*** Configure Multi-purpose Clock Generator (MCG) for 24MHz bus frequency
//Switching from FEI Mode to PEE Mode
//FEI --> FBE
MCGC2 = 0x36;
while(!MCGSC_OSCINIT); //loop until crystal has been initialized, OSCINIT = 1
DisableInterrupts; //disable interrupts so no extra steps occur in 1.5MHz range
MCGC1 = 0x98; //CLKS=10 (Ext. ref); RDIV=011 (12MHz/8=1.5MHz)
while(MCGSC_IREFST == 1); //loop until IREFST = 0; Ext. reference is source
while(MCGSC_CLKST != 0b10); //loop until external ref. clock is selected to feed MCGOUT
//FBE --> BLPE
MCGC2 = 0x3E; //LP = 1; BLPE MODE ON
EnableInterrupts;
MCGC3 = 0x48; //1.5MHz*32=48MHz; PLL is selected (prepared for PBE)
while(!MCGSC_PLLST); //loop until current source for PLLS clock is PLL; PLLST=1
//BLPE --> PBE
MCGC2 = 0x36; //LP = 0; BLPE MODE OFF, PBE MODE ENTERED
while(!MCGSC_LOCK); //loop until PLL acquired lock; LOCK=1
//PBE --> PEE
MCGC1 = 0x18; //CLKS = 00; output of PLL or FLL is selected
while(MCGSC_CLKST != 0b11); //loop until PLL output is selected to feed MCGOUT
//EnableInterrupts; //enable interrupts
//Initialize Inputs
PTGDD = 0; //initialize Port G as Input (Data Direction Register)
PTGPE = 0x0F; //pullups on (PTG0..3)
//Initialize Outputs
PTEDD = 0x0C; //initialize Port E bits 2 and 3 as Outputs
PTFDD = 0x13; //initialize Port F bits 0, 1, and 4 as Outputs
//*** Initialize TIMER module (TPM1)
//Since MCG is in PEE mode, MCGFFCLK=1.5MHz, fixed sys clock=750kHz (1.5MHz/2)
TPM1MOD = 0x493D; //modulo value (terminal count): 18,749
TPM1SC = 0x52; //fixed sys clk (750kHz), prescaler 4 (TPM1 CLK=187.5kHz)
TPM1SC_TOF = 0; //timer has not overflowed
//*** FOREVER LOOP
for(;
{
__RESET_WATCHDOG(); //feeds the dog
LED1 = BTH10;
LED2 = BTH1;
LED3 = BTM10;
LED4 = BTM1;
}
} /* please make sure that you never leave main */
/**************************END*MAIN********************************/