ATMEGA32basic programming tutorial: In the following ATMEGA32tutorial i used books to learn fundamental knowledge about Embedded system. After that i install Atmel Studio compiler and Proteus simulator tool to implement following basic ATMEGA32programming tutorial:
Operation of Internal ADC with ATMEGA32: In this tutorial Internal ADC is operating with AVR(ATMEGA32) controller. You need to enter password "1234#", you can use this tutorial for security checking projects. If you want to learn more kindly see tutorial on youtube as well.
>> Operation of Internal ADC with ATMEGA32C Code: ///////////////////// pin defined /////////////////// #define LCD_DIR DDRD #define CTRL_DIR DDRB #define LCD PORTD #define RS PORTB.F0 #define E PORTB.F1 ///////////////////////////////////////////////////// #include"lcd.h"
while(1) { z=ADC_read(0); cmd_lcd(0xc4); number_lcd(z,4); delay_ms(500); } } /********************* lcd.h **********************/ void cmd_lcd (unsigned char dat) // function to write command at lcd port { LCD=dat; RS=0; //clear RS (ie. RS=0) to write command E=1; // send H-L pulse at E pin delay_us(100); E=0; delay_us(100); }
void data_lcd (unsigned char dat) // function to write data at lcd port { LCD=dat; RS=1; // set RS=1 to write DATA E=1; // send H-L pulse at E pin delay_us(100); E=0; delay_us(100); }
void init_lcd() // function to initialize the LCD at power on time {
cmd_lcd (0x38); // 2x16 display select delay_ms(50); cmd_lcd (0x0c); // display on cursor off command delay_ms(1); cmd_lcd (0x06); // automatic cursor movement to right delay_ms(1); cmd_lcd (0x01); // lcd clear command delay_ms(5); }
void string_lcd(unsigned char *str) // function to display string to lcd { while(*str!='\0') // '\0' is null char as last char of pointer is null { data_lcd(*str); str++; } } void number_lcd(unsigned int dat, unsigned int siz) // function to display any digit decimal value to lcd { unsigned int temp,temparr[10];