Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
n8falkeN

n8falke

@n8falke
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Flickering problem with RGB leds and a simple solution
    n8falkeN n8falke

    Some background, why the solution works without changing the timer prescale:
    The default prescale of all timers are 64, so they should work the same, but the default mode is different:
    Timer 0: Fast PWM mode = 0..255,0..255,... (timer is used for internal calculations millis() / delay() /..., so this setting is required)
    Timer 2: Phase-correct mode = 0..255..0..255...
    Timer 1 is 16 bit and the pins are blocked by the radio, so I'll leave them out here.
    The frequency of the timer is comparable to a timer round trip (values are calculated with a 16 MHz IO-frequency like with ATmega168 or ATmega328 used in nano):
    Timer 0: 16 MHz / 64 / 256 = 976.5625 Hz
    Timer 2: 16 MHz / 64 / 510 = 490.1961 Hz
    Fast PWM uses 0..255 = 256 for a round trip.
    Phase-corrected mode uses 0..255,254..1 = 256 + 254 = 510 (all numbers are double except 0 and 255!)

    NOW the command:
    TCCR2A |= _BV(WGM21);
    Switches timer 2 to fast PWM mode (mode from 1 to 3).

    In addition to the links above, here I found the default settings: http://playground.arduino.cc/Main/TimerPWMCheatsheet

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular