I have a project where I'm generating audio tones with a 8-bit PIC microcontroller. At present I'm using the CCP module in PWM mode.
To generate a rise-fall siren, I'm stepping the frequency (PR2 value) every 50ms. There is a bit flag to keep track of whether I'm going up or down in value.
This works over a short range of frequencies, but since the on-time is fixed it leaves something to be desired.
Is there a way to use the PIC hardware to generate tones with 50% duty cycle without having to calculate the width (for the other registers) for each step?
There are comms (38400 baud) interrupts occurring all of the time so I don't think bit banging the tones is an option.