Difference between PWM and "regular" pin

Hello. I was looking through the data sheets on the Atmega168 and didn't really notice any mention of "PWM pins" nor any obvious differentiation between "them" and regular digital i/o pins. So, here I ask, what makes them special?

I've noticed that only the PWM pins seemed to be able to correctly send servo pulses at 50 Hz.. the regular pins have... too slow of a rise time? I need to put an oscilloscope to it. I just noticed that my delay-created duty cycle of 5%(1 ms every 20ms) resulted in a cap-smoothed voltage that was 20% of the voltage amplitude, whereas the PWM pins accurately produced a voltage-smooted signal of 5% of the voltage amplitude(5% of 5 volts). So, there's some difference as indicated there... but it seems the atmega168 folks believe arduino is monkeying with something as it shouldn't "normally" do that - they suggested I directly write to the registers using assembly language, except, I don't know how to do that. I was looking at the rise and fall times of the pins on the data sheet, and it seems they're "all" well within the range of creating a 1ms-high 50Hz servo pulse train so I'm guessing it's not purely hardware differences... or at least it wasn't originally.

So, what are the technical hardware differences or is it an arduino-bootloaded software hampering/enhancement? If so, is it possible to circumvent it with assembly language or would I have to remove some software? Or... what else could be done?

1 Like

All twenty pins are "regular digital i/o pins." They all support digitalRead(), digitalWrite(), and pinMode().

I'll go by the Arduino pin numbers, not the ATmega*8 pin numbers, just out of convenience when talking about the Arduino library API.

D0 and D1 are additionally tied to the FTDI chip and allow serial communication through the USB/serial port.

D3, D5, D6, D9, D10, D11 are additionally given access to internal comparators and timers, for PWM output with analogWrite().

D14 to D19 are additionally given access to internal analog-to-digital converters, for analog inputs with analogRead(). They are also known as A0 through A5 and it's this pin numbering scheme that analogRead() expects.

Halley, that's a brilliant explanation! I have been hunting around the forums and other places for just this kind of expose of the Arduino pins. I can't speak for swbluto, but for me the fog has finally cleared! ;D

Would you consider putting this with the other Arduino basics on the playground? It would probably help a lot of people sort out how to use Arduino.