[PIC] Independent PWM Control (dsPIC33f)

Status
Not open for further replies.

TMet

Newbie level 1
Joined
Nov 3, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
13
Hi,

I am fairly new to the pics and trying to balance between the cell voltages. I got a circuit to drive the mosfets when the balancing in need but i stuck with program. How can i enable and disable pwm signals independently?



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void init_PWM()
{
    //P1TCON = 0x0000;
    _PTMOD = 0x0; // PWM Time Base Mode Select bits  PWM time base operates in a Free-Running mode
    _PTCKPS = 0x0; // PWM Time Base Input Clock Prescale Select bits PWM time base input clock period is TCY (1:1 prescale)
    _PTOPS = 0x00; // PWM Time Base Output Postscale Select bits. 1:1 postscale
    _PTEN = 1; // PWM Time Base Timer Enable bit. PWM time base is on
 
    PTPER = 499; // PWM Time Base Period Value bits / PTPER+1  fPWM=20kHz fCY=20 MHz
 
    /*~~~~~~~~~~~~~~~~~~~~~~~ PWM1 Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    _PEN1H      = 0x1;                  /* PWM1H is controlled by PWM module */
    _PEN1L      = 0x1;                  /* PWM1L is controlled by PWM module */
    _PEN2H      = 0x1;
    _PEN2L      = 0x1;
    _PEN3H      = 0x1;
    _PEN3L      = 0x1;
    _PMOD1      = 0x0;                  /* Select Independent Output PWM mode */
    _PMOD2      = 0x0;
    _PMOD3      = 0x0;
    PDC1 = 500;             /* Initial Duty cycle PDCx/2 */
    PDC2 = 500;
    PDC3 = 500;
 
    PTCONbits.PTEN       = 1;           /* Enable the PWM Module */
 
}



Any help would be appreciated. Thanks
 
Last edited by a moderator:

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…