PWM Signals

Orangatan 1284P:

Can someone please tell me how to access each of the PWM outputs. I understand from the 1284P Data sheet that there are 6 on board PWM signals that can be generated. The only code that I have found is:

DDRB |= (1 << PB1) | (1 << PB2);  // or set_digital_output(IO_B1, LOW); set_digital_output(IO_B2, LOW);
// COM1 bits set to clear OC1A/OC1B on Compare Match when upcounting and
// set OC1A/OC1B on Compare Match when downcounting.
// WGM11:10 set for 9-bit phase-correct PWM
TCCR1A = 0xA2;
OCR1A = 384;  // 75% duty cycle on OC1A (PB1)
OCR1B = 128;  // 25% duty cycle on OC1B (PB2)
TCCR1B = 1;  // Timer1 clock = 20 MHz

I would like to be able to access all 6 PWM signals and be able to vary the Duty Cycle and Frequency of each.

Thank you

Hello.

Unfortunately, we do not have library code for generating arbitrary PWMs. The required code for all six outputs will be similar to the code you posted, and your best resource is the ATmega1284 datasheet, which explains how the timers and their associated registers work. If you find the datasheet confusing, please let me know and I can try to help you understand it.

- Ben

Can you please point me in the right direction in regards to the Data Sheet.

PWMs are covered in the sections on the timers.

By the way, you should note that not all of the ATmega1284’s hardware PWM outputs are available on the Orangutan SVP. Two are used as speed inputs to the motor drivers and one is used for the SVP’s buzzer. In general, setting up arbitrary PWMs on the hardware outputs could conflict with various parts of our AVR library, so you might be better off generating your PWMs in software using timer interrupts.

- Ben