I have two pushbuttons (on RA2 and RA3), a buzzer (on RC3/CCP2), and a small OLED display (hardware I2C on RC0/SCL and RC1/SDA) connected to a PIC16F1825. I also have Timer1 configured with a watch crystal for RTC.
I'm showing a weird problem with the PWM (using Timer2) for the buzzer (technically a magnetic transducer, not piezo). On a button press, I turn the buzzer on for a short time to generate a beep. And then turn it off. After three presses of either button, the PWM ends up idling in the HIGH state. It will still "beep", but it says ON after the beep. This causes an annoying hiss in the buzzer, and can't be good for it. PWM is configured for active HIGH, which return to LOW at the end of the period. I don't have any code that checks for "3". In fact, I'm sounding the buzzer only by turning on and off Timer2. Also, if I remove all of the display code (which is also on PORTC) the problem disappears. Just removing the writes to the display doesn't fix it I have to also remove the display initialization as well.
Is this some conflicting interaction between the MSSP and PWM? Why doesn't the PWM output return to LOW? And why only after the display has been initialized?
Is this caused by my method of controlling the PWM by switching Timer2 off? If so, what is the proper method of enabling and disabling PWM?
Sorry, no code...I'd have to work on reducing it to the minimum to cause the problem.
post edited by upand_at_them - 2020/09/20 14:29:11