AnsweredAssumed Answered

[S12ZVC] About using interrupt routine..

Question asked by daehyeon kim on Dec 22, 2016
Latest reply on Dec 23, 2016 by lama

Hello,

 

I got a S12ZVC evaluation board lately and I'm trying to test some source codes.

but I can not find the example source using interrupt for S12ZVC.

here is a simple code that I modified the timer example source. this isn't working.

could you please check this code?

 

ps.

I also want to use an interrupt routine like that,

interrupt routine

   if(TIM_flag) { ... }

   if(ADC_flag) { ... }

   if(RX_flag) { ... }

   ... continuing

}

can be including all case of interrupt counditions. is it possible?

 

 

//////////////////////////////////////////////////// Test code /////////////////////////////////////////////////////

 

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

 

 /* I CAN SEE RED UNDERLINE AT ISR ON THE CODE WARRIOIR.

BUT NO PROBLEM TO COMPLIE */

interrupt VectorNumber_Vtim0ovf void TIM_ISR()     
{
 TIM0TFLG2_TOF = 1;
 PTP_PTP6 ^= 1;
}

void main(void) {
 
 /********************************************/
 /************ PLL INITIALIZATION ************/
 /********************************************/
 CPMUCLKS_PLLSEL = 1;   //FBUS = FPLL/2.   FBUS = 32MHz,
 CPMUREFDIV_REFFRQ = 1;   //Reference clock between 2MHZ and 6MHZ. 
 CPMUREFDIV_REFDIV = 0x1;  //FREF=8/(1+1) = 4MHZ  
 CPMUSYNR_VCOFRQ = 0x1;          //FVCO is between 48MHZ and 80MHZ 
 CPMUSYNR_SYNDIV = 0x7;   //FVCO = 2xFREFx(SYNDIV+1)   =   FVCO = 2x4x(7+1) = 64MHZ
 CPMUPOSTDIV_POSTDIV = 0x0;  //FPLL = FVCO/(POSTDIV+1).  FPLL = 64MHZ/(0+1)    FPLL = 64MHz 
 CPMUOSC_OSCE = 1;    //External oscillator enable. 8MHZ.        FREF=FOSC/(REFDIV+1)  
 while(!CPMUIFLG_LOCK){}   //Wait for LOCK.       
 CPMUIFLG = 0xFF;    //clear CMPMU flags
 
 /********************************************/
 /*********** GPIO INITIALIZATION ************/
 /********************************************/
 
 //Use PP6 as output for LED
 DDRP_DDRP6 = 1;
 DDRP_DDRP5 = 1;
 DDRP_DDRP4 = 1;
 DDRP_DDRP0 = 1;
 
 PTP_PTP6 = 1;
 PTP_PTP5 = 1;
 PTP_PTP4 = 1;
 PTP_PTP0 = 1;
 
 /********************************************/
 /************ TIM INITIALIZATION ************/
 /********************************************/
 
 //1. Configure the prescaler (TSCR2[PR]).
 TIM0TSCR2_PR = 0b111;   // Bus Clock / 128
 
 //2. Configure needed channels as Input Capture (TIOS[IOSx]=0) or Output Compare (TIOS[IOSx]=1).
 TIM0TIOS = 0;
 
 //3. Enable interrupts if needed in the timer interrupt enable register (TIE). (Input Capture/Output Compare Interrupt)
 TIM0TIE = 1;
 
 //4. Set the timer enable bit (TSCR1[TEN]).
 TIM0TSCR1_TEN = 1;
 
 EnableInterrupts;

 for(;;){

 }
}

Outcomes