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
Anonymous
Not applicable

 Hi,

   

 

   

Please have a look at http://www.cypress.com/?app=forum&id=167&rID=61042. Keil will ingore the interrupt TMR1_VECTbecase of  #pragma NOIV, which tells keil do not generate interrupt vectors. #pragma NOIV affects only the source file on which it is added. Make a new source file for your timer ISR. It should work.

   

 

   

Regards,

   

Gayathri

0 Likes
Anonymous
Not applicable

Thank you very much!

   

I put the interrupt service function in a new file and the timer works very good.

   

Another problem:I just want to drive the DA max5384 in my interrupt service function,but keil told me that

   

*** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE:   CODE   
    SEGMENT: ?PR?ISR_SUTOK?BULKLOOP
    LENGTH:  0016H
*** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE:   CODE   
    SEGMENT: ?PR?ISR_SOF?BULKLOOP
    LENGTH:  0016H
*** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE:   CODE   
    SEGMENT: ?PR?DR_GETCONFIGURATION?BULKLOOP
    LENGTH:  0012H

   

and so on...

   

Here is the source code:

   

void MAX5384(WORD point)
{
 BYTE i,j;
 point&=0x0ff0;
 for (i=0;i<16;i++)
 {
  DASCLK=0;
    for(j=0;j<2;j++);//time delay

   

  DADIN=(point>>(15-i))&((WORD)(1<<i));//serial transfer,msb first
        for(j=0;j<2;j++);

   


  DASCLK=1;        //clock

   

  for(j=0;j<2;j++);
 }
  DASCLK=0;
}
 

   

void ISR_TIMER2(void) interrupt 5
{
 BYTE i,j;
 WORD mydata;
 TF2=0;
    if(x)//flag
  {
  //mydata=0xffff;
 MAX5384(0xffff);
 x=0;
 }
 else
 {
 //mydata=0;
 MAX5384(0);
 x=1;
 }
}

0 Likes
Anonymous
Not applicable

 Hi,

   

 

   

This error is related to the address space constraints. This may arise if the values entered in Keil settings is conflicting against the actual code size. Please double check the values that you have provided at Project – Options for Target Dialog box. You would have specified the code range values either in the "Target"  tab or in the "BL51Locate" tab. Please odify the value according to your application, and this should sove your issue.

   

 

   

Regards,

   

Gayathri

0 Likes