The AVR is a Modified Harvard architecture 8-bit RISC single chip microcontroller (µC) which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to One-Time Programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

Getting To Know AVR And C Programming

August 8th, 2009

Ok, it's almost 5 am and I need to go to bed!

I think I am finally starting to get how things work with AVR and kits. My first working code I got to work (without any walk through or tutorials) that blinks an LED every 100ms on a Atemega168 MCU on pin 26 (PC3):

 
/*
comments www.nerdful.com
*/

#include <avr/io.h>
#include <avr/delay.h>
void sleep(uint8_t millisec)
{
while(millisec)
{
delay_ms(1);
millisec--;
}
}
main()
{
DDRC |=1<<PC3;
while(1)
{
PORTC &= ~(1<<PC3);
sleep(100);
PORTC |=(1<<PC3);
sleep(100);
}
}
Here's a helpful image (others)

:

The above code uses no libnerdkits include files supplied by the kit maker www.nerdkits.com, only includes provided by WinAVR/AVRdude. When I first got this kit about 60 hours ago, I thought I was only stuck using the files in libnerdkit which would limit the source codes and samples I could find on the internet, but thankfully I am not limited to only what NerdKits makes on the bootloader or with the include files. I was also falsely believing that these include files were on the MCU itself (but now realize these files are on my PC when I do the make command to compile). I guess I was assuming it was like PC where you can have different operating systems and I was thinking that NerdKit was some new unknown linux release but I was expecting Windows or something like that.

 Now I can understand better controling a simple on/off device. Next i will attempt to make it dim instead of flash on off, I'm assuming that has to do with pulse width modulation (PWM).Kind of like how you speed down/up and normal DC motor (usually goes almost full throttle). Then I will try a servo, 3V DC motor, and other parts that I have ordered.



Comments:

No comments yet. You could be the first person to comment!

Make A Comment:

Name:

Your message/comment:

characters left.
For AVR codes, use my PasteBin & post link.

Prove you are human (enter the text seen in image):


Make your own email signatures like this @ www.text2logo.com


Free image widgets HERE.