EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key 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
  • Advertise
You are here: Home / Replies / Hi..check this functions

Hi..check this functions

|

Microcontroller › AVR › I have ATMEGA 16 i want to serial communication to pc terminal. › Hi..check this functions

February 25, 2013 at 6:52 am #9179
jagadeesh
Participant

Hi..

check this functions once….

 

 

     //UART0 initialize
     // desired baud rate: 9600
     // actual: baud rate:9600(0.2%)
     // char size: 8 bit
     // parity: Disabled
void UART_Init(void)
{
     // At 4MHz oscillator
     int baud = 25;
 
     /* Set baud rate */
     UBRRH = (unsigned char)(baud>>8);
     UBRRL = (unsigned char)baud;
 
     /* Enable Receiver and Transmitter */
     //RXCIE TXCIE UDRIE RXEN TXEN UCSZ2 RXB8 TXB8
     UCSRB = 0;
     UCSRB = (1<<RXCIE)| (1<<RXEN) | (1<<TXEN);
 
     /* Set frame format: 8data, 1stop bit */
     //URSEL UMSEL UPM1 UPM0 USBS UCSZ1 UCSZ0 UCPOL
     UCSRC = 0;
     UCSRC = (1<<URSEL)| (1<<UCSZ1)| (1<<UCSZ0);
}
 
 
void UART_TransmitByte( unsigned char data )
{
      /* Wait for empty transmit buffer */
      while ( !( UCSRA & (1<<UDRE)) );
     /* Put data into buffer, sends the data */
     UDR = data;
}
 

 

RSS Recent Posts

  • renewed interest in old project I call it WICKED 8 January 23, 2026
  • Expensive hobby January 23, 2026
  • analog logic of shmidt trigger bjt circuit January 23, 2026
  • getting no where fast 8 x 8 led matrix January 23, 2026
  • Micro mouse January 22, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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 | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key 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
  • Advertise