Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I have an ATtiny85 and I'm trying to set the clock to 8Mhz. I have read the data sheet and some discussions on how to do this but am not having any luck getting it to work. I have included my code and any help will be greatly appreciated.

#include <avr/io.h>
#include <avr/interrupt.h>


int main(void)
{
    cli();
    CLKPR |= 1<<CLKPCE;
    CLKPR |= 0;
    sei();

    DDRB |= 1<<PINB1 | 1<<PINB0;

    TCCR0A |= 1<<WGM00 | 1<<WGM01 | 1<<COM0B0 | 1<<COM0B1;
    TCCR0B |= 1<<CS00;
    OCR0B = 240;

    TCCR1 |= 1<<PWM1A | 1<<COM1A0 | 1<<CS13 | 1<<CS12 | 1<<CS11 | 1<<CS10; 
    OCR1C = 255; 
    OCR1A = 127;

    while (1)
    {
    }
}

I do not have a scope so I'm not able to determine what the frequency of Timer0 is but I know that timer1 is running at around 61hz (prescaler = CK/16384) because I timed the blinking of a led. That would meet that the CK is still at 1Mhz. Not sure what i'm doing wrong here.

share|improve this question

1 Answer

up vote 1 down vote accepted

Obviously I figure out what I was doing wrong after posting a question. The following changes fixed it.

CLKPR = 0b10000000;
CLKPR = 0;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.