pic 18f4620 pwm (enhanced) half bridge mode

Thread Starter

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
what is the problem please help me
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
Mod edit: added code tags
 
Last edited by a moderator:

JohnInTX

Joined Jun 26, 2012
4,787
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).
Try adding while(1); after init_().

You don't have any useful comments in the code so its hard to know what speed / duty the PWM is supposed to be running at.
 
Top