Henry_Best:
strajke:
I am working on PWM code (varying duty cycles) in which I used a Sine wave lookup table.
The code I have is based off of this site:
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/I use timer two and the OC2B and OC2A registers (pin 3 and 11). Both pins generate the same output except one is an inverted output.
OCR2A=pgm_read_byte_near(sine256 + icnt_a);
//Read value from sine table and send to PWM DAC
// (ORCR2A will be non inverted PWM)
OCR2B=pgm_read_byte_near(sine256 + icnt_a); //ORCR2B will be inverted PWM
How? You're giving them both the same value. You appear to be missing a "!"
It is done by setting up up and down counting in the TCCR2A register by setting COM2A0,COM2A1 for OCR2A and COM2B0,COM2B1 for OCR2B