Friday, July 26, 2019

AVR programming

The following software is used to program the AVR.
1. download WinAVR and Mfile
2. Proteus simulator (if you have hardware tool that much better but can initiate with Proteus software)

At the very beginning test your startup code with aid of the following code. It will blink all LEDs which connected to the PORTC in  each 500ms,

# include<avr/io.h>
# include<util/delay.h>

int main(void){  // shoul have one main funtion in c,

DDRC = 0xFF; // data direction registor of portc set as OUTPUT

while(1){       // start endless loop
PORTC=0xFF;   // portc HIGH
_delay_ms(500);  // delay for 500ms
PORTC=0x00;  // portc LOW
_delay_ms(500);  // delay 500ms
}
return 0; 

}

1. Open Winavr and create a new page and save it as MAIN.C in any new blank folder.
2. Open Mfile and make the setting for a) AVR select == Atmega 328
                                                               b) Port  === USB
                                                               c) Programmer== USBasp
3. Then save it as Mekefile in the SAME FOLDER that you made for MAIN.C
4. Then write the first code and compile it.
5. Open the Proteus and simulate it using the HEX file.


Downloads



Search This Blog