Astralist
Newbie level 5
Hello All,
I'm currently building an interface to HD44780 LCD, and needs PWM to drive the backlight.
For some electrical rules on PCB, i can only set PWM at P1A/RC5, but i'm unable to get it done, even with ISIS Proteus simulation, its outputs nothing.
Here is the code for the PWM for lowest possible frequency, at 48MHz fosc:
also, when i try to set output at all (P1A, P1B, P1C, and P1D) by setting:
The PWM outputs on all but P1A. :bang::bang::bang:
What happened here? am i missing something? i've searched all websites and people can actually steer PWM to single pin @ P1A with the code above.
p.s: i'm using USB framework, and i'm sure nothing interfere with timer 2 or RC5 pin.
I'm currently building an interface to HD44780 LCD, and needs PWM to drive the backlight.
For some electrical rules on PCB, i can only set PWM at P1A/RC5, but i'm unable to get it done, even with ISIS Proteus simulation, its outputs nothing.
Here is the code for the PWM for lowest possible frequency, at 48MHz fosc:
Code:
void InitializePWM(void){
TRISCbits.TRISC5 = 0;
CCP1CON = 0b00001100;
CCPR1L=0;
PSTRCON = 0b00010001; //pulse output at P1A/RC5
//PWM1CON = 0b10000000;
//ECCP1AS = 0b00000100;
T2CON = 0b00000111;
TMR2 = 0;
PR2 = 0b11111111;
}
void PWMdc(uint8_t duty){
CCPR1L = duty;
}
also, when i try to set output at all (P1A, P1B, P1C, and P1D) by setting:
Code:
PSTRCON = 0b00011111;
The PWM outputs on all but P1A. :bang::bang::bang:
What happened here? am i missing something? i've searched all websites and people can actually steer PWM to single pin @ P1A with the code above.
p.s: i'm using USB framework, and i'm sure nothing interfere with timer 2 or RC5 pin.