Saturday 12 October 2013

Arduino ISP(In System Programming)


Using arduino isp you can program a AVR. Avr is the heart of arduino, the arduino uno has a ATmega328p( the "p" stands for  pico power, less power and more effiency.) If you go ahead and open the arduino isp form file-->examples-->arduino isp.
If you scroll down you can see the pin configuration on your arduino and the Avr( note that your AVR pin configuration can differ). 

First you have to power the AVR using 5V and GND. the you have to connect the actual communication pins. MOSI( MASTER OUT SLAVE IN), MISO( MASTER IN SLAVE OUT), SCK(THE CLOCK) AND THE RESET. and you have to put 10uf capacitor to diasable auto reset.  Then Google "winavr" and install it.




Here is the AVR led blink. open and write this into programmers notepad. THIS PICTURE IS NOT MINE!!!










/***********************************************************************
make sure to attach a LED to + to PB0 and - to GND.
written and created by randipa. project 1.2

*************************************************************************/
#define F_CPU=8000000; // setting the cpu clock make sure to divide the crystal oscilator by 8;
#include <util/delay.h> // including the delay header
#include <avr/io.h> // including iostream to avr


int main(){
DDRB = 0xff; // data direction port b. using hex. 0xff= 0b11111111 setting all of it to output.
PORTB = 0; // setting port b to 0V.


  While(1){

      PORTB = 0;
      _delay_ms(100) // delay 100ms
      PORTB = 0xff;
      _delay_ms(100)  //if your are too lazy type PORTB^=0xff; _delay_ms(100);  this will xor which will invert.

 }
 retun 0;
}

save this in the c directory.
Goto CMD and "cd .." press enter "cd .." press enter again. And type "avrdude -c avrisp -p m328p -U flash:w:ledblink.hex"
(without any quotes) make sure use -p to your avr part.

Bootloader?

You might be wandering if you can program avr and arduino in one language. yes You can avr and arduino has a different language because of the bootloader. bootloader is a firmware(you can only write.) Bootloader is the piece of code which runs when the power was supplied. the bootloader recognise the code and do everything else. if you want to do this search google " bootloader avr arduino" Only do this if you know what you are doing(I tried this and bricked my ATmega8)

13107@csc.school.nz
11127@csc.school.nz

No comments:

Post a Comment

Note: only a member of this blog may post a comment.