So I got my grubby paws on a handful of skt500 boards and want to learn how to program microcontrollers and make cool things.
Does anyone have any reference guides, how to's, recommended reading for me?
I think it programs in assembler or C so some help in this direction would also be appreciated.
Thanks.
Edit:
Useful Resources.
Basic Info:
Projects:
Atmel AVR Microcontroller programming
- Prime
- Registered User
- Posts: 27729
- Joined: 01 Mar 2004, 02:00
- Location: Getting into trouble
- Contact:
Atmel AVR Microcontroller programming
Last edited by Prime on 23 Apr 2010, 21:18, edited 1 time in total.
- Prime
- Registered User
- Posts: 27729
- Joined: 01 Mar 2004, 02:00
- Location: Getting into trouble
- Contact:
Re: Atmel AVR Microcontroller programming
Right, got a C compiler and a basic tut for it. Will try find and post the links.
Something fun I just programmed.
I used an existing template and played with the parameters in the while loop.
8 LED's; 8 switches.
The first LED is on. Pressing the first button switches the second one one and switches the first off; IE it shifts the state to the right.
If you press and hold buttons 1,2 and 3; only LED 4 lights. if you press it's corresponding button, LED 4 and LED 5 switch states.
http://www.elec.uow.edu.au/avr/index.php
Something fun I just programmed.
I used an existing template and played with the parameters in the while loop.
Code: Select all
// File: led.c
// Description: Simple C program for the ATMEL AVR uC (ATMEGA16 or ATMEGA8515 chip)
// This program lets the user turn on LEDs by pressing the switches on STK500 board
// Date modified: 23 April 2010
#include <avr/io.h> // avr header file for IO ports
int main(void){
unsigned char i; // temporary variable
DDRD = 0x00; // set PORTD for input
DDRB = 0xFF; // set PORTB for output
PORTB = 0x00; // turn ON all LEDs initially
while(1){
// Read input from PORTD.
// This port will be connected to the 8 switches
i = PIND+1;
i = PIND-1;
// Send output to PORTB.
// This port will be connected to the 8 LEDs
PORTB = i;
}
return 1;
}
The first LED is on. Pressing the first button switches the second one one and switches the first off; IE it shifts the state to the right.
If you press and hold buttons 1,2 and 3; only LED 4 lights. if you press it's corresponding button, LED 4 and LED 5 switch states.
http://www.elec.uow.edu.au/avr/index.php
-
- Registered User
- Posts: 1
- Joined: 12 Dec 2011, 23:00
Re: Atmel AVR Microcontroller programming
If you're using AVR Studio 5 (which I would recommend coz it's based on MS Visual Studio 2010) then you'll be coding in c. here is some code to make a led change status every second with the delay feature.
connect led's to portb of your avr, compile and program your avr with the following code and voila!
Have fun!
connect led's to portb of your avr, compile and program your avr with the following code and voila!
Code: Select all
#ifndef F_CPU
#define F_CPU 16000000UL //yout oscillator frequency
#endif
#include <avr/io.h>
#include <util/delay.h> //need to include this for the _delay to work
int main(void)
{
DDRB=0xFF; // PORTB data direction = all output
PORTB=0x00; // PORTB all off (low)
while(1)
{
PORTB=0xFF; // PORTB all high
_delay_ms(1000);
PORTB=0x00; // PORTB all low
_delay_ms(1000);
}
}
- Prime
- Registered User
- Posts: 27729
- Joined: 01 Mar 2004, 02:00
- Location: Getting into trouble
- Contact:
Re: Atmel AVR Microcontroller programming
How far I have come!
Learning how to use SPI at the mo... alas my jtag programmer seems to have died
Learning how to use SPI at the mo... alas my jtag programmer seems to have died
-
- Registered User
- Posts: 4
- Joined: 28 Mar 2012, 16:57
Re: Atmel AVR Microcontroller programming
Hi
http://forums.trossenrobotics.com/forum.php has a pretty nice section about micro-controller programming. Also, it's robots, how much more could you possibly want?
http://forums.trossenrobotics.com/forum.php has a pretty nice section about micro-controller programming. Also, it's robots, how much more could you possibly want?