Hey all..
ive ben recommended that this site is ace... and im hoping its true lol...
im interfacing triacs with a PIC 16F877A... and i need a PWM period of 20ms (50Hz) with a 10% or so duty cycle...
now ive read a few posts on here regarding getting this and its pretty hard to get 20ms period on pwm module but i still dont get it..some people HAVE got 20ms period by choosing correct register values??? but they havent put up their register values... im using a 20MHz xtal... which i believe is a 200ns cycle time...i preferebaly wouldnt like to reduce the crytsal but if its the ONLY way then i will do.
im using the timer2 for the PWM module as instructed by datasheet, and CCP1 as the PWM output pin...
at the moment ive set PR2 at its max...256 and 16 postscaler and 16 prescaler, and i should get 13.1ms
but i dont i get a freq of 1.2kHz on my scope...which doesnt give a period of 13.1ms... HELPPPPPP im a n00b and im gonna admit it lol
ive ben recommended that this site is ace... and im hoping its true lol...
im interfacing triacs with a PIC 16F877A... and i need a PWM period of 20ms (50Hz) with a 10% or so duty cycle...
now ive read a few posts on here regarding getting this and its pretty hard to get 20ms period on pwm module but i still dont get it..some people HAVE got 20ms period by choosing correct register values??? but they havent put up their register values... im using a 20MHz xtal... which i believe is a 200ns cycle time...i preferebaly wouldnt like to reduce the crytsal but if its the ONLY way then i will do.
im using the timer2 for the PWM module as instructed by datasheet, and CCP1 as the PWM output pin...
at the moment ive set PR2 at its max...256 and 16 postscaler and 16 prescaler, and i should get 13.1ms
but i dont i get a freq of 1.2kHz on my scope...which doesnt give a period of 13.1ms... HELPPPPPP im a n00b and im gonna admit it lol
Code:
MOVLW h'ff' ;Setup PR2 for PWM
MOVWF PR2
...............
..............
MOVLW d'50' ;Random number for testing purposes...i get 20% duty with this
MOVWF CCPR1L ;Set duty cycle
MOVLW b'00001100'
MOVWF CCP1CON ;Mode Select PWM
MOVLW b'01111111' ;post scaler 16/prescaler 16
MOVWF T2CON