dsPIC30F4011 PWM MC Issue [ There is a approx 2sec delay between PWM1L and PWm1H]

Status
Not open for further replies.

baileychic

Advanced Member level 3
Joined
Aug 2, 2017
Messages
728
Helped
56
Reputation
112
Reaction score
57
Trophy points
28
Activity points
7,033
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.

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?
 

Attachments

  • Logic_2019-04-25_15-09-22.png
    135 KB · Views: 103
  • Logic_2019-04-25_15-09-46.png
    138.1 KB · Views: 102
  • Logic_2019-04-25_15-12-35.png
    135.4 KB · Views: 98

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…