Author Topic: Attiny45/85 clock problem  (Read 2074 times)

0 Members and 1 Guest are viewing this topic.

Offline mrmp17Topic starter

  • Contributor
  • Posts: 38
Attiny45/85 clock problem
« on: December 19, 2013, 05:44:03 pm »
Hi

I have some problems with my little project that contains attiny85 microcontroller. I can't get attiny85 to work properly  :-\. It seems like the clock runs somehow to slow.

If  I write a very simple code (I write in Atmel Srudio 6.1) that togles led on the output (1000ms on, 1000ms off) it stays on and off for about 9 seconds. This test program uses util/delay.h with defined F_CPU (I'll post the code below).  Also a program I downloaded seems to work just fine but about 9 times to slow.

I was playing with fuses, tried everything but....doesn't work... Same thing with external crystal oscilator. I tried with attiny45 but it does the same thing. The code I wrote works prfectly on atmega32 with internal RC oscilators and external crystal.

I need to get attiny microcontrollers working but I don't know what to do ,so a little help would come handy  :-\  What am I doing wrong?


Code: [Select]
#define F_CPU 8000000UL

#include <avr/io.h>
#include <util/delay.h>


int main(void){

DDRB = 0b11111111;
PORTB = 0b11111111; 

while(1){
           
   PORTB = 0b00000000;
   _delay_ms(1000);
   PORTB = 0b11111111;
   _delay_ms(1000);
   
    }
}

 
 

Offline Hideki

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: no
Re: Attiny45/85 clock problem
« Reply #1 on: December 19, 2013, 06:07:20 pm »
Did you try the turning off the CKDIV8 fuse? The default is to divide the clock by 8.

If you want to be sure it's running at full speed, you can also override the division by setting the CLKPR register.
 

Offline mrmp17Topic starter

  • Contributor
  • Posts: 38
Re: Attiny45/85 clock problem
« Reply #2 on: December 19, 2013, 08:49:55 pm »
Thank you!  :-+

Didn't even knew of this fuse  :palm: ....Everything works just fine now!
It's strange that this fuse is enabled in default fuse setings.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf