My Buzzer is connected to CCP4 on the 18F8722 PIC at 40 MHz
As i understand, HPWM does not support Channels 3 - 5 so i must enter the registers manually. I have checked the calculator and it was very useful however, i was using the "Sound" command and was producing several sound to create a tone.
Is is possible for someone to help out with the formula on calculating the actual PR4 and CCPR4L values? My current configuration is as follows:
Code:
'CCP4 PWM (Buzzer) Declares
Dim CCP4_Duty As byte
symbol CCP4_Period = PR4
CCP4_Duty = 124
CCPR4l = CCP4_Duty
ccp4_period = 62
clear trisg.3
CCP4CON = %00011100 'Set CCP4 for PWM Mode
T3CON.6 = 1 'Timer3 and Timer4 are the clock sources for ECCP1, ECCP2, ECCP3, CCP4 and CCP5
T3CON.3 = 1
t3con.0 = 1
T4CON = %00000111 'Timer4 Prescaler 1:16, Timer ON
For example i have the following command:
Code:
Sound Buzzer, [100,10,120,10]
Based on the Calculator the values for tone "120" (Approx 9000 - 8000KHz) the values would be :
PR4: 68
CCPR4L & 2 bits from CCP4CON : 10001001 (137)
But what formula is used to calculate these values?