My name is Mike; I am a soft dev and I started working on electronics a few weeks ago.
I got a ATMega168p micro controller (not from a kit or anything) and I am using a breadboard to mount my mini project on it.
I got a simple example that should blink a led.
Here is the code:
- Code: Select all
#include <avr/io.h>
#include <util/delay.h>
void Wait()
{
uint8_t i=0;
for(;i<23;i++)
_delay_loop_2(0);
}
void main()
{
//Set PORTC0 as output
DDRC=0b00000001;
while(1)
{
//Set PC0=High(+5v)
PORTC|=0b00000001;
Wait();
//Set PC0=Low(GND)
PORTC&=0b11111110;
Wait();
}
}
I compiled the code using AVR Studio 5.0.
I uploaded the code using avrdude but something is missing.
Questions:
-As a brand new micro controller, should I upload a bootloader? What is it good for?
-How should I update the fuses (can avrdude do that for me?)
-What am I missing to upload?
uhe wrote:AFAIK it just runs when you apply power.
-How does the micro know I want to program it with avrdude or any other uploader.
If I provide power the micro should start running the code right?
Does it stop running it when I start uploading software to it?
(Kind of) Does the ship say "ok, I stop running the program and let you upload new firmwork"
A few specifics:
-I use winXP, my uploaded is a serial COM2; I had no problem with AVRdude (write, read, check OK)
-The AtMega168 is a new one, no pre-burned.
Thanks a lot for your feedback uhe.
I appreciate all the help I can to get me started on this new programming avenue.
Mike.

