Atmega162 with Arduino Ide
Although he added the atmega162 support to arduino ide, but the support lacks the serial interface(uart). Uart initialization and data sending commands Seial.begin() and Serial.send() did not work if using the above support provided by some one. So i decided to ope-rationalize the atmega162 microcontroller uart by individual register configuration. I made a separate header file for uart initialization and working “Uart.h”. In uart.h i defined the values for individual uart registers. Uart initialization code in c++ and assembly is given in the atmega162 datasheet. Almost all the atmega series microcontrollers uarts are initialized using the same registers, the registers are same for almost all the microcontrollers. I copied the initialization code from there. For full description of the registers and code i recommend to see the data sheet.
Most important register in initializing Uart is UBRR. Its a 16 bit register. Divided in to two 8- bit registers UBRRL and UBRRH. In order to set the desired baud rate. We have to calculate the value for this register. The formula for calculating the value is given on right side. “Baud Rate” is the desired baud rate that we need. Fpb is the clock/crystal frequency on which the microcontroller is working. UxBRG is UBRR 16-bit register. After calculating the value, upload the higher 8-bits in UBRRH and lower 8-bits in UBRRL.
Atmega162 Serial Communication with MAX232(Rs232 Interface)
Atmega162 Serial Communication with FT232(USB to Uart Interface)
A status led is connected to pin#25. It blinks after every second. Shows the program status, if the hardware is working or not. Note: The led is connected to pin#25 where as in code its declared as pin#22, its because for programming the pins are assigned different numbers. Remember the upper tutorial see that for more clarification.
Watch the Project Video Here.
Serial Communication using Uart of 8051(89c51,89c52) microcontroller
Serial Communication using Uart of Pic16f877 Microchip microcontroller
Serial data Transmission using 89c51 Communication
Serial rs485 communication between arduino uno and leonardo
Serial Communication using Atmega32A
Serial data received from pc using Microchip Pic Microcontroller