I'm using a dsPIC30F3011 and I need to obtain a different duty cycle on PWM1L and PWM1H with both channels working at the same frequency ( 50Hz ). My code looks like this:
Code: Select all
void sinit(void) {
PWM1_Mc_Init(50,1,0x11,15);
PWM1_Mc_Start();
}
void sopen(void) {
PWM1_Mc_Set_Duty(900,0); // left - PWM1L - 0,9ms
PWM1_Mc_Set_Duty(4400,1); // right - PWM1H - 4,4ms
}
void sclose(void) {
PWM1_Mc_Set_Duty(2900,0); // left - PWM1L - 2,9ms
PWM1_Mc_Set_Duty(2400,1); // right - PWM1H - 2,4ms
}
void main() {
sinit();
while(1) {
sopen();
Delay_ms(2000);
sclose();
Delay_ms(2000);
}
}