Currently the latest version is Atmel Studio 7. You can download it freely from Microchip website.
After we download and install it on our PC, let get started.
Open Atmel Studio 7, From File Menu ->New->Project
Atmel Stuio 7 IDE |
Choose C/C++ language, select GCC C Executable Project, and Click OK Button.
Atmel Device Selection Window |
In the Device Selection Window, scroll to select Atmega32 and click on OK Button
Programming Windows |
In the main.c file try to write a test program.
/*
* example_1.c
*
* Created: 4/24/2020 9:57:39 PM
* Author : admin
*/
#include <avr/io.h>
//F_CPU set the frequency for delay.h
#define F_CPU 16000000UL
#include "util/delay.h"
#define dTime 1000
int main(void)
{
PORTC=0x00; //Clear PORTC
DDRC=0xFF; //Set PORTC AS OUTPUT
/* Replace with your application code */
while (1)
{
PORTC=0x00; //Clear PORTC
_delay_ms(dTime); //Wait for 1 second
PORTC=0xFF; //PORTC ON
_delay_ms(dTime); //Wait for 1 second
}
}
After complete the code writing, press F7 key to build the project.
Building the project |
After building the project successfully, the IDE generate hex and other files in the Debug folder of the project directory.
Now I want to upload the hex file to Atmega32 via an ISP programmer. I use a DIY usbasp.
This programmer need any software interface like AVRDude.
I use AVRDude with GUI to progrm this device.
Now I open this program to flash the hex file into chip.
AVRDUDESS IDE to flash the firmware |
The pictures below show the running example on my ATmega32 board.
Back to main tutorial page ATMega32 tutorials in C with Atmel Studio 7.
No comments:
Post a Comment