baileychic
Advanced Member level 3
dsPIC30F4011 PWM MC Issue [ There is a approx 2sec delay between PWM1L and PWM1H id DTCON1 is used]
10 MHz XT XTAL with x8 PLL = 80 MHz clock is used.
mikroC PRO dsPIC Compiler is used.
This is my code.
All variables in the above code are unsigned int type.
If I comment the
line then I get correct PWM MC signals that is both PWM1L and PWM1H start at the same time. With
I get incorrect signal that is PWM1H starts after approx 2 sec after PWM1L starts.
Initially when device starts there is 200ms delay for LCD and then after PWM MC is started with 0% duty there is a 20ms delay and then a 150ms timer4 interrupt runs and ramps the duty from 0% to 50% in 7.5 seconds.
7500ms/50 = 150ms
I need 2us DT and I am getting it with
See attached images.
It is just the DTCON1 causing the issue.
Fosc = 80 MHz
FCPU = Fosc/4 = 20 MHz
Tcy = 1/20MHz = 50ns
2000ns/50ns = 40 = 0x28 for DTCON1
You can see in one of the attached image that I am getting exact 66.67 kHz PWM MC signal (Tpwm = 15us) and DT measured with cursors = 2us.
Duty cycle updating and all other things are working fine. It is just the DTCON1 configuration causing the issue.
I am using EasyPIC v7 for dsPIC30F development board.
How to fix the issue?
10 MHz XT XTAL with x8 PLL = 80 MHz clock is used.
mikroC PRO dsPIC Compiler is used.
This is my code.
Code:
// Complementary PWM signals on RE0 and RE1 of dsPIC30F4011
// Test freq: 66.66 Khz
// Required frequencies: 50 KHz, 66.66 KHz, 75 KHz, 100 KHz, 125 KHz
inverter.pwm.duty100 = PWM1_MC_Init(66660, 1, 0x11, 1);
inverter.pwm.i = ceil((double)inverter.pwm.duty100 / 100.0);
DTCON1 = 0x28;
PWM1_MC_Set_Duty(0, 1);
PWM1_MC_Start();
All variables in the above code are unsigned int type.
If I comment the
Code:
DTCON1 = 0x28
line then I get correct PWM MC signals that is both PWM1L and PWM1H start at the same time. With
Code:
DTCON1 = 0x28
I get incorrect signal that is PWM1H starts after approx 2 sec after PWM1L starts.
Initially when device starts there is 200ms delay for LCD and then after PWM MC is started with 0% duty there is a 20ms delay and then a 150ms timer4 interrupt runs and ramps the duty from 0% to 50% in 7.5 seconds.
7500ms/50 = 150ms
I need 2us DT and I am getting it with
Code:
DTCON1 = 0x28;
See attached images.
It is just the DTCON1 causing the issue.
Fosc = 80 MHz
FCPU = Fosc/4 = 20 MHz
Tcy = 1/20MHz = 50ns
2000ns/50ns = 40 = 0x28 for DTCON1
You can see in one of the attached image that I am getting exact 66.67 kHz PWM MC signal (Tpwm = 15us) and DT measured with cursors = 2us.
Duty cycle updating and all other things are working fine. It is just the DTCON1 configuration causing the issue.
I am using EasyPIC v7 for dsPIC30F development board.
How to fix the issue?