AnsweredAssumed Answered

setting a PWM signal of 100khz in ADuC7060

Question asked by mgat on Mar 30, 2013
Latest reply on Mar 30, 2013 by MMA

Respected Sir/Madam,


We are finding difficulty to set a 100Khz in PWM timer for ADuC7060 in my extract is as follows:



// Bit Definitions

#define BIT0  0x01

#define BIT1  0x02

#define BIT2  0x04

#define BIT3  0x08

#define BIT4  0x10

#define BIT5  0x20

#define BIT6  0x40

#define BIT7  0x80

#define BIT8  0x100

#define BIT9  0x200

#define BIT10 0x400

#define BIT11 0x800

#define BIT12 0x1000

#define BIT13 0x2000

#define BIT14 0x4000

#define BIT15 0x8000

#define BIT16 0x10000

#define BIT17 0x20000

#define BIT20 0x100000

#define BIT24 0x1000000

void ConfigurePWM(void);




unsigned char bTripDetected = 0;

int main(void)




          POWKEY1 = 0x1;

          POWCON0 = 0x78;                       // Set core to max CPU speed of 10.24Mhz

          POWKEY2 = 0xF4;


          // Initialize the GPIO pins for PWM mode

          GP0CON0 = BIT16;                      // Select PWM1 output

          GP1CON  = BIT8 + BIT12           // Select PWMSYNC and PWMTRIP functions

                              + BIT16 + BIT20           // Select PWM2, PWM3 output

                              + BIT24;                     // Select PWM4 output

          GP2CON  = BIT0 + BIT4;           // Select PWM0 and PWM5          output


          PWMCON          = BIT0 + BIT10;           // PWM Standard mode, UCLK/2, PWM Trip interrupt enabled


          ConfigurePWM();                              // Call function to configure PWM

          bTripDetected = 0;

          IRQEN          = BIT17;                     // Enable PWM Trip interrupt source

          while (1)


             if (bTripDetected == 1)


                                 bTripDetected = 0;









void IRQ_Handler(void) __irq  // Unused in this application


   unsigned long IRQSTATUS = 0;



          IRQSTATUS = IRQSTA;             // Read off IRQSTA register



          if ((IRQSTATUS & BIT17) == BIT17)          //If PWM trip interrupt source


                     bTripDetected = 1;                    // Set flag to re configure the PWM block

                     PWMCLRI = 0xFF;                    // Clear the PWM trip interrupt source



void ConfigurePWM(void)


   //Configure PWM0 for 20khz duty cycle

   // P0.4

          PWM0COM0 = 0x80;                    //          Configure PWM0 output high trigger time

          PWM0COM1 = 0xFF;                    //          Configure PWM0 output Low trigger time

          PWM0COM2 = 0x80;                    //          Configure PWM1 output low trigger time

          PWM0LEN = 0xFF;                    //          Configure PWM1 output high trigger time



          //Configure PWM2 for 10khz duty cycle

          // P1.5

          PWM1COM0 = 0xFF;                    //          Configure PWM2 output high trigger time

          PWM1COM1 = 0x1FF;                    //          Configure PWM2 output Low trigger time

          PWM1COM2 = 0xFF;                    //          Configure PWM3 output low trigger time

          PWM1LEN = 0x1FF;                    //          Configure PWM3 output high trigger time



          //Configure PWM4 for 40khz duty cycle

          // P2.1

          PWM2COM0 = 0x40;                    //          Configure PWM4 output high trigger time

          PWM2COM1 = 0x80;                    //          Configure PWM4 output Low trigger time

          PWM2COM2 = 0x40;                    //          Configure PWM5 output low trigger time

          PWM2LEN = 0x80;                    //          Configure PWM6 output high trigger time