An AVR PWM subtlety

[ad_1]

LilyTiny SparkFun

The original idea was not to use Arduino with the Arduino programming language, which resilts in rather slow PWM outputs, but to use Arduino hardware and assembler-code the PWM bit which can yield waveforms at hundreds of kHz.

Anyway, it transpires that setting an AVR counter to ‘fast PWM’ mode can result in an output frequency a fraction off from the one expected.

Luckily, arduino.cc has a clear explanation why (scroll down).

It transpires that the reference clock is divided by one more than the number you put in the appropriate register.

Do have a look, many AVRs have excellent flexible fast PWMs.

The picture is SparkFun’s LilyTiny, which can source one complementary pair of PWM waveforms and a single PWM waveform (portB bit4 is not bought out, so no complement).

[ad_2]

Source link

Leave a Reply