I'm running Ubuntu 12.10, and I want to be able to use gcc and avrdude to compile and program my ATmega328.
I followed this Ladyada tutorial: Ladyada AVR Tutorial
Everything installed perfectly, no errors or warnings. I have not installed avrdude yet, but that is beside the point.
I use the command:
avr-gcc -O0 -c blink_1MHz.c -o main.o
However, I get one warning, and many errors:
warning "device type not defined" error: 'PORTC' undeclared (first use in this function)
The error above repeats itself for each Port and each Data Direction Register used in the code.
blink_1MHz.c is just some simple code I'm using to test my setup. It has worked on my Windows setup through AVR Studio 6.
I've tried Google, but the only real suggestion I got was to import the libraries:
#include <avr/io.h> #include <stdlib.h> #include <stdint.h>
Unfortunately, still nothing. I've been playing around with this for a while and I'm simply stumped. I saw suggestions that avr-libc isn't installed, but I have installed avr-libc. I would think that if I didn't have it installed, I would be seeing complaints about the libraries not existing.
Could an enlightened individual suggest what may be the cause of these errors? Thanks.
Amoch pointed out that I needed to check out avr/io.h; there you will see that you need to define the processor with the -mmcu flag. In my case, I have an ATmega328, so my command looked like:
avr-gcc -O0 -c blink_1MHz.c -mmcu=atmega328 -o main.o