AnsweredAssumed Answered

ADuC7129 PWM

Question asked by jakpil on Oct 31, 2013
Latest reply on Dec 4, 2013 by MMA

Hi,

I want to use all 6 PWM outputs in uC separately to generate impulse 1ms- 2ms with period of 20ms. I calculated everything and get correct values. Problem is that to achieve six completely separate outputs I must reverse all outputs. My question is : Is bit 5 (POINV) i register PWMCON1 work correctly? In my code changing the bit doesn't change output polarity.

 

GP3CON &= ~(0xF << (PWM1 << 2));

GP3CON &= ~(0xF << (PWM2 << 2));

GP3CON &= ~(0xF << (PWM3 << 2));

GP3CON &= ~(0xF << (PWM4 << 2));

GP3CON &= ~(0xF << (PWM5 << 2));

GP3CON &= ~(0xF << (PWM6 << 2));

GP3CON |= (1U << (PWM1 << 2));

GP3CON |= (1U << (PWM2 << 2));

GP3CON |= (1U << (PWM3 << 2));

GP3CON |= (1U << (PWM4 << 2));

GP3CON |= (1U << (PWM5 << 2));

GP3CON |= (1U << (PWM6 << 2));

 

PWM1LEN = SERVO_PERIOD; //20ms

PWM2LEN = SERVO_PERIOD;

PWM3LEN = SERVO_PERIOD;

 

PWM1COM3 = SERVO_MAX;

PWM1COM2 = 5222;

PWM1COM1 = 5222 + SERVO_MAX;

 

PWM2COM3 = SERVO_MAX;

PWM2COM2 = 5222;

PWM2COM1 = 5222 + SERVO_MAX;

 

PWM3COM3 = SERVO_MAX;

PWM3COM2 = 5222;

PWM3COM1 = 5222 + SERVO_MAX;

 

//     PWMCON1 = 0x38E1;

PWMCON1 = 0x38E1;

 

This code should generate 1ms impulse witch period 20ms on all 6 outputs.

Outcomes