0

I'm trying to use the ATTiny85 to control a bunch of LEDs. The LEDs have to be run at around 2Khz ( this is so that it doesn't flicker when being filmed). How would I change the frequency of PWM signals?

Cat Beard
  • 11
  • 1
  • 1
  • `2Khz` does not grant that the led does not flicker when filmed. It depends on many things, first the refresh rate of filming cam. – LPs Sep 15 '16 at 07:41
  • Also the exposure time of each frame. – rjp Sep 15 '16 at 13:06
  • While this is true with the default LED frequency of 60Hz. At 2Khz It will not flicker in each frame regardless if it's 24/30 fps. Exposure of each frame won't matter either since 1/2000 won't make a difference. This is for television and film. – Cat Beard Sep 15 '16 at 18:48

2 Answers2

1

You can change it by setting different prescaler.

For Timer/Counter0 are available prescaler values: 1/8/64/256/1024.
So if you have 8MHz clock, and full 8bits PWM resolution you'll get: 31.25kHz / 3.9kHz / 448.28Hz / 122Hz / 30.5Hz

For Timer/Counter1 are available prescaler settings: 1 / 2 / 4 / 8 / 16 / ... / 16384. And it can be sourced by internal PLL clock (32MHz/64MHz).
So you can have prescaler set to divide source clock by 16 and at 8MHz clock it'll be 1953.125Hz.
With PLL Clock 32MHz division by 64 is needed and for 64MHz it's 128. But using PLL Clock is not needed for such small output frequencies.

KIIV
  • 3,534
  • 2
  • 18
  • 23
0

I am not too familiar with this microcontroller, but from the documentation, it seems that you would like to configure the TCCR0B register (bits 2:0, refer to pages 79-80). There, you can select a different prescaler, or no prescaler at all.

MayeulC
  • 1,628
  • 17
  • 24