Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > Anyone succeeded to use the timer2 on cy68013 as a pwm?

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



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

Post Reply
Follow this topic



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

prcxjb posted on 09 May 2012 10:48 PM PST
Member
6 Forum Posts

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;
 
}

 




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

Gayathri posted on 09 May 2012 12:30 AM PST
Cypress Employee
428 Forum Posts

 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

 



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

prcxjb posted on 11 May 2012 03:44 AM PST
Member
6 Forum Posts

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;
 }
}



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

Gayathri posted on 11 May 2012 04:15 AM PST
Cypress Employee
428 Forum Posts

 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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20