Yes the internal CCP module set in PWM will handle it for you AND in background.
Depending you OSC speed you'll have more or less DutyCycle resolution. But anyway, you want it 50% right?
Unfortunately due to it's limitations, PBP HPWM won't help. You'll need to calculate and write the right value to the PIC registers.
To do ALL related calcs, i will suggest to use my PicMultiCalc available bellow
http://www.mister-e.org/pages/utilitiespag.html
Once you have it, it's piece of cake.
Here's something working @4MHZ
Code:
'
' 38KHz PWM @ 4MHZ using a PIC16F877
' ----------------------------------
@ __CONFIG _XT_OSC & _LVP_OFF
'
'
TRISC = 0
Duty var byte
'
' PWM SETUP
' =========
' PicMultiCalc says..
' Duty value for 50%=52
' PR2 = 25
' PRESCALLER 1:1
'
'
duty = 52 ' duty value for 50% duty cycle
PR2 = 25 '
T2CON = %00000100 ' timer2 on, prescale 1:1
CCPR1L = duty>>2 ' MSB of duty cycle value
CCP1CON=%00001100 | (dUTY<<5) ' set PWM mode and store the
' 2 LSB of duty
SpinInRound:
goto spininround
also have a look to those...
http://rentron.com/PicBasic/IR_Chips.htm
http://rentron.com/IR_TO_RF.htm
http://rentron.com/Infrared_Communication.htm
Last edited by mister_e; - 25th February 2007 at 22:49.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks