Hi,
After a number of Arduino Uno projects I decided to move on to programming an ATMega328p MCU. So I am still a total noob at this. I'm having issues with hello world. The code I am using is the following
#define F_CPU 1000000UL #include <avr/io.h> #include <util/delay.h> int main(void) { DDRB |= _BV(DDB0); while(1) { PORTB ^= _BV(PB0); _delay_ms(500); } }
I understand what it does but it doen't seem to blink the LED. My setup is as follows
So the black wire is attached to GND. The red wire is attached to PB0. In order to program the MCU I'm using the AVRISPmkII and I am executing the following commands in order to get it on the chip.
avr-gcc -Os -Wall -mcall-prologues -mmcu=atmega328p -fno-exceptions -o main main.c avr-objcopy -R .eeprom -O ihex main main.hex avrdude -p m328p -P usb -c avrispmkII flash:w:main.hex
The output of running this is
avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.01s avrdude: Device signature = 0x1e950f avrdude: safemode: Fuses OK avrdude done. Thank you.
Thanks for your help!