C code balancing robot

Thread Starter

john_doe01

Joined Nov 27, 2011
24
Hi
new to the forum

im in my last year of uni, doing a two wheeled balancing robot for my last year project

being made to use a PIC18f452

at the moment ive just started coding and im having difficulty setting up the second channel for the PICs PWM output
The first PWM channel works fine and im not sure what im missing for the second

any help will be appreciated and ill keep updating the projects status

basic code below:
PR2= 0xff; // Period
T2CON= 0x05; // Timer 2 on and Prescaler = 4
CCPR1L= 0x20; // Dutycycle
CCP1CON= 0x0C; // PWM mode on

CCPR2L= 0x20; // Dutycycle
CCP2CON= 0x0C; // PWM mode on

TRISC= 0x00; // port C output (bit 2)
 
Top