# pic 18f4620 pwm (enhanced) half bridge mode

#### spidermanIIII

Joined Nov 22, 2013
78
hi, i want to make pwm and its complementary for half bridge so i choose pic 18f4620 but it give me one pwm but the complementary doesn't appear i read the datasheet he datasheet
C:
//names

//var

//modules
void init_(){
trisc.b2=0;
portc.b2=0;

trisd=0;
portd=0;

CCP1CON=0b10001100;

TMR2=0;

PR2=124;
CCPR1L=20;

T2CKPS1_bit=1;
T2CKPS0_bit=0;
TMR2ON_bit=1;
}//init_

void main() {
//setup
init_();
//loop

} //main

Last edited by a moderator:

#### JohnInTX

Joined Jun 26, 2012
4,669
For one thing, you don't have a loop in main. That means that the processor will run init and then be reinitialized by the C runtime when it exits main (it will loop back and run main again and again).