lfuse and now a change in clock frequency

MiniPOV4 and previous versions

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
northalb
 
Posts: 1
Joined: Sun Aug 29, 2010 8:45 pm

lfuse and now a change in clock frequency

Post by northalb »

greetings.
My newly assembled POV3 kit worked fine when running all of the firmware code provided.
I tried to load ledcube.hex provided by the online tutorial at make magazine.
Everything seemed fine until the lfuse error appeared during the download.
After looking through the forum, I entered 'n' when asked about changing the
setting. The fuse question was asked three more times..each answered, 'n'...
the execution ended and then 'nothing'.
Using the dasa downloading, all the original .hex files run as before; however,
although files digg.c and minipov.c each download fine they run too fast.
The frequency of the LED's are so high that they almost look like they are just on.
I went through the Makefile and found the line for 'burn-fuse' and ran it
on the command line. There was no change to the LED frequency.
As a newbie, I'm assuming that some prescaler (?) in the Tiny2313 clock setting
must have been changed ?!?
I know I'm close....
I would sure appreciate any suggestions.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: lfuse and now a change in clock frequency

Post by adafruit »

dont think so, the minipov3 is already running on the 8mhz internal oscillator and thats as fast as it goes. try mucking with the frequency divider line to change the speed?

LEDTim
 
Posts: 4
Joined: Tue Sep 21, 2010 4:12 pm

Re: lfuse and now a change in clock frequency

Post by LEDTim »

Does anyone know if I can slow this Minipov3 waaaaaaaaaaay down??? And how to do it??

Tim

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: lfuse and now a change in clock frequency

Post by adafruit_support_bill »

The timing calculation is described in detail at the beginning of the main() function in mypov.c. You can play with the prescale and/or overflow values until you get the effect that you want.

LEDTim
 
Posts: 4
Joined: Tue Sep 21, 2010 4:12 pm

Re: lfuse and now a change in clock frequency

Post by LEDTim »

I'm missing it. I don't do alot of programing. I have changed all kinds of things and can't get it to slow down. Then reloaded the file from source code and started again.
Could you please copy and paste what lines of code I need to change.
Thanks
Tim

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: lfuse and now a change in clock frequency

Post by adafruit_support_bill »

Code: Select all

  /*
    the frequency of the interrupt overflow is determined by the 
    prescaler and overflow value.
    freq = clock_frequency / ( 2 * prescaler * overflow_val)
    where prescaler can be 1, 8, 64, 256, or 1024
    clock_freq is 8MHz
    and overflow_val is 16bit

    the overflow value is placed in OCR1A, the prescale is set in TCCR1B
    so for example:
    A good POV frequency is around 400Hz
    desired freq = 400Hz
    clock freq = 8MHz
    8MHz / (400Hz * 2) = 10000
    since 10000 is less than 655536 (largest 16 bit number)
    OCR1A = 10000 and the prescale is 1
  */

  TCCR1B = (1 << WGM12) | TIMER1_PRESCALE_1;
  OCR1A = (uint16_t)10000;

  TIMSK |= 1 << OCIE1A;   // Output Compare Interrupt Enable (timer 1, OCR1A) 
If you increase the prescale, things will get slower. For example, you could change TIMER1_PRESCALE_1 to TIMER1_PRESCALE_8 to run 8 times slower.
Or you can increase the value assigned to OCR1A. If you change the 1000 to a 2000 it will be half as fast.

Locked
Please be positive and constructive with your questions and comments.

Return to “MiniPOV”