Thursday, April 3, 2014

ATmega328p programming for Arduino UNO R3

Arduino UNO R3 Schematic

ATmega328p for Arduino UNO R3 fuses:
low fuses: 0xff
high fuses: 0xde
extFuses: 0x05
unlock bits: 0x3f
lock bits: 0x0f

1. first, erase flash
2. then write flash
3. timer

Programming the AVR ATmega328p with AVRDUDE
avrdude -p m328p -c usbtiny -e -U flash:w:led.hex


// F_CPU tells the compiler that our crystal is an 16Mhz one so it can
// generate an accurate delay, must be declared above delay so delay
// knows what is the value of F_CPU
#define F_CPU 16000000UL

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

int main (void)
{
    DDRB |= _BV(DDB5);
 
    while(1)
    {
        PORTB ^= _BV(PB5);
        _delay_ms(1000);
    }

    return 0;
}

No comments:

Post a Comment