AnsweredAssumed Answered

[S12ZVC] HVI Interrupt is working but can't wake up

Question asked by daehyeon kim on Jan 5, 2017
Latest reply on Jan 5, 2017 by Radek Sestak

Hello,

 

Thank you for your assistance.

I want to make MCU waking up when I push the button on the evaluation board.

This button is connected to HVI0 directly, it is pulled down to ground if I push the button.

So I configured this working by falling edge as wake up interrupt source. (PPSL)

Anyway, the HVI interrupt seems to be working properly and I can see the led toggling.

But after 10 sec, MCU enter the stop mode, this interrupt does't work.

is there anything I missed?

 

 

//////////////////////////////////////////////// HVI TEST CODE /////////////////////////////////////////////////

#include <hidef.h>
#include "derivative.h"

int m_sec = 0;
int sec = 0;

void interrupt 12 TIM_OutputCompare_ISR(void)
{
 TIM0TC0 = TIM0TCNT + 1000;
 TIM0TFLG1 = 0b00000001;
  
 m_sec++;
 if(m_sec == 250) {
  PTP_PTP0 ^= 1;
  sec++;
  m_sec = 0;
  if(sec == 10) {

   sec = 0;
   asm STOP;
  }
 }
}

interrupt 79 void HVI_ISR(void)
{
 PTP_PTP6 ^= 1;
 PIFL = 0x01;
}

void TIM_init(void)
{
 TIM0TIOS = 0b00000001;
 TIM0TCTL1 = 0b00000000;
 TIM0TCTL2 = 0b00000000;
 TIM0TFLG1 = 0b11111111;
 TIM0TTOV = 0b00000000;
 TIM0TIE = 0b00000001;
 TIM0PTPSR = 31;
 TIM0TC0 = TIM0TCNT + 1000;
  
 TIM0TSCR1 = 0b11101000;
}

void main(void)
{
 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; 
 
 TIM_init();
 
 asm ANDCC #0x7F;
 
 DDRP_DDRP0 = 1;
 DDRP_DDRP4 = 1;
 DDRP_DDRP5 = 1;
 DDRP_DDRP6 = 1;
 
 PTP_PTP0 = 1;
 PTP_PTP4 = 1;
 PTP_PTP5 = 1;
 PTP_PTP6 = 1;
 
 PPSL_PPSL0 = 0;
 PTAENL_PTAENL0 = 0;
 DIENL_DIENL0 = 1;
 PIEL_PIEL0 = 1;
 
 EnableInterrupts;
  
 for(;;)
 {
 
 }
}

Outcomes