Hi,
I am working on PIC16LF1939. I have implemented Piezo buzzer but when I check the frequency is not at required 2.7khz. What could be the reason?
Here is my settings.
#define Piezo_freq 2700
#define _XTAL_FREQ 16000000
CCP2CON = 0x0C; /// PWM Mode
T2CON = 0x06; /// Enable TMR2 with pre-scaler = 16
PR2 = (uint8_t) (((_XTAL_FREQ) / (Piezo_freq * 4 * PIEZO_TMR2_PRESCALER)) - 1);
I always get 2.0 KHz with above values. What value needs to be changed to get 2.7 khz.
Thanks & regards,
Sarvanan.
I am working on PIC16LF1939. I have implemented Piezo buzzer but when I check the frequency is not at required 2.7khz. What could be the reason?
Here is my settings.
#define Piezo_freq 2700
#define _XTAL_FREQ 16000000
CCP2CON = 0x0C; /// PWM Mode
T2CON = 0x06; /// Enable TMR2 with pre-scaler = 16
PR2 = (uint8_t) (((_XTAL_FREQ) / (Piezo_freq * 4 * PIEZO_TMR2_PRESCALER)) - 1);
I always get 2.0 KHz with above values. What value needs to be changed to get 2.7 khz.
Thanks & regards,
Sarvanan.