Hey all,
I'm kind of new at AVRs and C but I know Java pretty well. Many of my friends use CB and I thought to try it as well and I like it much better than PN2.
I wrote a simple 'Hello World' kind of program that I want to burn on an ATMEGA168 AVR.
Here is the code:
#define F_CPU 1000000UL
#include <inttypes.h>
#include <avr/io.h>
#include <util/delay.h>
void _delay_ms(); // Function deceleration
int main(void)
{
DDRB = 0b11111111; // Set PORTB pins as output
PORTB = 0b00000000; // Set output on all pins to logic 0
while(1)
{
PORTB=00000000; // LED OFF - at bit 0
_delay_ms(500); // Wait 0.5 sec
PORTB=00000001; // LED ON - at bit 0
_delay_ms(500); //Wait 0.5 sec
}
return 0;
}
I've noticed a few "strange things".
1. On every tutorial I saw no one defined function prototypes before main, but I'll get all kind of errors if I won't do that. Do I really have to do that?
2. On the tutorials I saw the function was called delay_ms and not _delay_ms, however the one without the underscore won't work.
3. I have WinAVR installed so I changed the default compiler to GNU AVR GCC and set the path to WinAVR folder. After I build the file I will get an EXE file but not a HEX file like I need to burn to the MC. How can I solve this?
Thanks!