Determine Oscillator Value

Hi all, it my first time when I post in this forum, and also a newbie in the embedded programming.

:? I have a some questions about how to set-up a microcontroller atmega328p-mu and determine the quartz speed.

So I have a board femtoduino, that had a 16mhz oscillator, when I change it with a 8Mhz one, I think I accidentally messed them up, and now I don’t know what oscillator is on the microcontroller. I can’t see the value on them because I accidentally pus some solder on them, the writing was small and I couldn’t see the value with a magnifying glass.

The tension regulator was changed with a 3.3v one.

So here is what I’m asking.

  1. Why I can’t read the device id in avr studio if I supply a 3.3v only if I supply 5v, the microcontroller works after if I switch to 3.3v. The programmer is a Pololu USB AVR Programmer.

  2. How to set the fuses right? Starting from the assumption that the oscillator is the right one (8MHz). What should I select for starting time?

  3. How can I determine after setting the fuses right if the oscillator is 8MHz or 16MHz. I don’t have a oscilloscope, I was thinking if I could determine using delay_ms, but before I get to learning process I want to make sure I have the proper hardware for my needs, so a sample code will be highly appreciated (for testing the value of oscillator).

So thanks I guess, if you need more details, please ask.

Have a nice day,

Vlad

Program a 1 second blinky.

Blinks at 1 second, oscillator is right.

Blinks at twice per second, oscillator is wrong.

Blinks every 2 seconds, oscillator is wrong.

Doesn’t blink, something else is wrong.

  1. ???

  2. Profit.

Ok, got it!

I set up this sample code.

#include <avr/io.h>

#define F_CPU 8000000

#include <util/delay.h>
     
int main(){   
    DDRC = 0xFF;
     
    while(1){
       PORTC = PORTC ^ 0x01;
       _delay_ms(1000);
    }
   
    return 0;
}

I got the fuses value right from a tutorial.

I will test it when I get home.

The thread remains opened for the first question.

P.S.:

1st question: when I can’t program the chip, the

tension (5v) is applied on the VIN pin and runs through the

voltage regulator (3.3v). When I can program the chip the tension (5v) is applied on the VCC pin (no voltage regulator).

wld91:
when I can’t program the chip, the

tension (5v) is applied on the VIN pin and runs through the

voltage regulator (3.3v). When I can program the chip the tension (5v) is applied on the VCC pin (no voltage regulator).

From the Programmers product page:

The programmer is powered by the 5V USB power bus, and it is intended for programming AVRs that are running at close to 5 V (note that the programmer does not deliver power to the target device)

Thank you codlink.

[SOLVED] :slight_smile: