Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Atmega32A microcontroller Uart programmed with Arduino Ide

By EG Projects April 30, 2019

In my last tutorial i added the atmega32 microcontroller support for arduino ide. All the interfaces worked perfect but the serial interface does not respond properly. It only sends some odd characters to the receiving channel also uart is unable to receive the characters. I was unable to use the serial commands Seial.begin(), Serial.receive(), Serial.available() etc. The error is in the atmega32 microcontroller uart pins initialization. Arduino uart default pins library has uart on pin#0,1. I tried to make changes in the atmega32 pins_arduino.h header file but it did not worked for me. So i decide to initialize the registers associated with the uart in the arduino code it self. This way i can use the atmega32 uart to be programmed with arduino ide. Before beginning any further please be sure that you installed the atmega32 microcontroller support for arduino ide. The link is below in case if you did not installed the support libraries.  
Atmega32A Programmed with Arduino IDE

​The code which i have written is tested by max232 uart to rs232 level converter. Atmega32 uart is connected to input of max232 and max232 output to DB-9 port of my old desktop computer. I used putty to check the serial communication and its works fine. I also tested the code with ft232 usb to uart driver on my laptop and it also gave me 100% result. The circuit diagram of both the circuits are given below.

Atmega32A Microcontroller with Max232 and Arduino Ide 

Atmega32A Uart interface with max232 and arduino ide

Atmega32A Uart interface with max232 and arduino ide

Atmega32A Microcontroller with ft232 USB to Uart and Arduino Ide 

Atmega32 with ft232 usb to uart and arduino ide

Atmega32 with ft232 usb to uart and arduino ide

Important register in initializing Uart of Atmega32 is UBRR. Its a 16 bit register, divided in to two 8-bit registers UBRRL and UBRRH respectively. UBRR must be initialize the correct value to achieve the desired baud rate at uart port. 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.
Atmega32A uart baud rate setting formula

Atmega32A uart baud rate setting formula

The uart pins of atmega32 are at pin#14 RXD and pin#15 TXD. In the code below i am sending my website name as output. At the receiving side we must receive “microcontroller-project.com”. The baud rate on which i send the data is 600. A status led is connected to pin#21 of the atmega32 microcontroller. It blinks every 1 second, shows if the system is working or not. USART_init() function is initializing the uart. Uart communication is taking place in asynchronous mode, baud rate 600bps, 8 data bits, 2 stop bits and with no parity. Be sure to set these settings correctly at the receiving side.
To upload the code to microcontroller i used and external programmer USBasp. Since their is no boot loader written for atmega32 so we can not program it directly from arduino ide. Please take the above “Atmega32 Programmed with Arduino Ide” if you are facing problems in uploading the code to atmega32 using arduino ide.

Note: At 9600 baud rate i am getting errors i could not figure out why. So I set the baud rate for serial communication to 600bps, its not a big speed. 4800 bps also worked for me. 

Download the project “Atmega32a Programmed with Arduino IDE” .ino file/folder and give us your valuable feed back on the project. Your feed back helps us improving the post, any bug found in code or circuit will be highly appreciated. For more projects related to Uart and serial communication please search the site. Don’t forget to like our face book page.

More projects related to Serial Uart communication using different microcontrollers are listed below. Each project circuit diagram and source code is open source, you can modify code according to your needs.

  • Serial communication using atmega162 microcontroller
  • Serial communication using 8051(89c51,89c52) microcontroller
  • ​Serial communication using Pic microcontroller 
  • ​Serial communication RS485 between arduino
Atmega32A Project files


Filed Under: Arduino Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Sendust vs Ferrite for SMPS
  • connector model question
  • value of feedback resistance in self biased inverter
  • Industrial Relay Board Design for Motorcycle Use
  • sim7090g

RSS Electro-Tech-Online.com Discussions

  • ac current limiting
  • using a RTC in SF basic
  • It's Amazing What A Buck And A Quarter....
  • Microinverters and storeage batteries?
  • More fun with ws2812 this time XC8 and CLC

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Infineon launches 3D magnetic sensors with ±50 mT to ±160 mT measurement ranges
  • Nexperia adds 1200 V 20 A silicon carbide Schottky diodes to power portfolio
  • EPC introduces 15 ARMS per phase motor drive in 32 mm diameter form factor
  • Non-contact angle sensors deliver +0.3% linearity across full measurement range
  • TDK introduces RGF board-mount EMI filters for high-current power supply applications

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe