I am trying to modulate 2 servos using the CCP1 and ECCP1 pins on the PIC.
the motor which is using the CCP1 pin is working as expected but the servo on the ECCP1 pin isn't moving. the code im using is as follows:
i am using microchip's C18 compiler.
is it a code problem or something else?
thanks in advance.
the motor which is using the CCP1 pin is working as expected but the servo on the ECCP1 pin isn't moving. the code im using is as follows:
Code:
#include <p18f458.h>
#include <pwm.h>
void main (void)
{
//PWM settings for a frequency of 50Hz */
TRISCbits.TRISC2 = 0; //PWM-pin ON
T2CON = 0b00000101; //timer2 on
PR2 = 0x7c;
/*setting up A/D converter as ADCON0 all pins are analouge and adcon0 channel selected */
/* 00 = FOSC/2 | 000 = AN0 Channel | 0 = Go/Done | 01 = A/D On */
ADCON0 = 0b00000000;
/*Forward Both wheels (5% Duty Cycle)*/
/*left wheel*/
CCPR1L = 0b00000110;
CCP1CON= 0b01001100;
/*right wheel*/
ECCPR1L = 0b00000110;
ECCP1CON = 0b00001100;
while(1);
}
i am using microchip's C18 compiler.
is it a code problem or something else?
thanks in advance.