Hi all:
I want to drive a piezo (9khz resonant) with a pwm pin in a 16f882.
I plan to use it for alarms and for button press beeps/chirps.
So far, It seems I have to set up prescale/Tmr2/PR2 registers to dictate the frequency of the PWM.
I am not sure what the necessary PW is though. would 50% work? Also, How do I switch on and off the PWM signal, by TRIS?
Lastly, are there elegant ways to map a couple bits from one register to another?
If I want to map bits 2,3 in a register to bits 6,7 in another register, there should be a simple elegant way to do this without btfss/bsf/bcf structures? Some combination of logical operations & bitmasking?