Hallo Leute,
beim RP6 wird mit Timer2 gepiepst:
Das müßte dann ja Fast PWM mit TOP OCR2 sein?Code:void beep(uint8_t pitch, uint16_t time)
{
controlStatus.beep = true;
sound_timer = time;
OCR2 = 255-pitch;
TCCR2 = (1 << WGM21) | (1 << COM20) | (1 << CS22) | (1 << CS21);
}
Als Teiler ist wohl 256 vorgesehen (bei 16 MHz).
Wie muss ich dann den pitch berechnen?
Wäre das so richtig: pitch = 255 - (16000000 / 256 / f[Hz] / 2) ?
Gruß Dirk