Anyone succeeded to use the timer2 on cy68013 as a pwm?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I just follow the template of C51,but nothing happend.

   

I put timer2 interruppt service function in fw.c and set the interruppt number to 1 according to the advice from somebody else,but still failed.

   

void TD_Init(void)             // Called once at startup
{
   WORD i,freq=1000;
   i=1000000/freq;

   

   // set the CPU clock to 48MHz
   //CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
   //CPUCS = CPUCS  ;
   // set the slave FIFO interface to 48MHz
   //IFCONFIG |= 0x40;
   IFCONFIG=0;
   CKCON&=~bmBIT5;
  
   RCAP2H=MSB(0xffff-i);
   RCAP2L=LSB(0xffff-i);
   //T2CON=bmBIT1;
   OEA=0x00;
   PA0=1;
   EA=1;
   TR2=1;
   ET2=1;

}

   

void ISR_TIMER2(void) interrupt 1
{
 TF2=0;
 
 PA0=~PA0;
 
}

0 Likes
3 Replies