Go Down

Topic: Moving PWM pins to other pins (Read 1 time) previous topic - next topic

jtw11

So, as with all my posts recently - I'm working on my own board for a project, using AVR chips. Quick question about PWM pins.

What, in general - or more specfically, on the Arduino - why are the PWM pins where they are? I can't seem to find a reason on the datasheet, I can see why there are two PWM pins on each port, so the frequencies can be different for each pair of PWM pins.

Is it just an ease of location thing, or are the PWM pins hardware specific?

westfw

PWMs are implemented by the "Output Compare" function of the chip's timer peripherals, which are located on fixed pins.
(OC0A, OC0B, OC1A, OC1B, OC2A, OC2B in the datasheet.)

jtw11


cyclegadget

SoftPWM Library
An Arduino and Wiring Library to produce PWM signals on any arbitrary pin.

It was originally designed for use controlling the brightness of LEDs, but could be modified to control servos and other low frequency PWM controlled devices as well.

It uses a single hardware timer (Timer 2) on the microcontroller to generate up to 20 PWM channels.

http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation

Note: I had problems using hardware PWM with SoftPWM in the same sketch because my Arduino would hang up. If you use SoftPWM you can use it on all of the Uno pins including the pins that are normally hardware PWM.

fungus


So, as with all my posts recently - I'm working on my own board for a project, using AVR chips. Quick question about PWM pins.

What, in general - or more specfically, on the Arduino - why are the PWM pins where they are? I can't seem to find a reason on the datasheet, I can see why there are two PWM pins on each port, so the frequencies can be different for each pair of PWM pins.

Is it just an ease of location thing, or are the PWM pins hardware specific?


The chip has three timers, each with two outputs.

No, you can't move them to other pins.
Advanced Arduino

Go Up