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 / Topics / I have ATMEGA 16 i want to serial communication to pc terminal.

I have ATMEGA 16 i want to serial communication to pc terminal.

|

Microcontroller › AVR › I have ATMEGA 16 i want to serial communication to pc terminal.

  • This topic has 4 replies, 3 voices, and was last updated 12 years, 8 months ago by Pulkit Prajapati.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • February 25, 2013 at 4:19 am #2136
    Pulkit Prajapati
    Participant

    I have ATMEGA 16 i want to serial communication to pc terminal.I got garbage value at any baudrate.and in simulation nothing display in virtual terminal….

    following is my code

     

    #define BAUD_PRESCALE 79
    #include<avr/io.h>
    #include<util/delay.h>
    void usart_init();
    void usart_putch(unsigned char send); 
    int main()
    { unsigned char send;
    _delay_ms(50); // delay of 50 mili seconds
    usart_init(); // initialization of USART
    while(1)
    {
    send =8;
    usart_putch(send); // send data back to the PC (HyperTerminal)
    }
    return 0;
    } 
    void usart_init()
    {
    UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitry
    UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes
      UBRRH = (BAUD_PRESCALE >> 8);
    UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value.. // into the low byte of the UBRR register
    // Load upper 8-bits of the baud rate value..// into the high byte of the UBRR register
    } 
    void usart_putch(unsigned char send)
    {
    while ((UCSRA & (1 << UDRE)) == 0){}; // Do nothing until UDR is ready..
    // for more data to be written to it
    UDR = send; // Send the byte 
    }
     
     
     
    sir plz help me quick….thanx in advance..
    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;
    }
     

     

    February 25, 2013 at 9:18 am #9180
    Pulkit Prajapati
    Participant

    it show me for p-> x…

    February 27, 2013 at 6:09 pm #9192
    AJISH ALFRED
    Participant

    May be hardware issue. Please post your circuit diagram

    March 1, 2013 at 8:12 am #9211
    Pulkit Prajapati
    Participant

     

    wysiwyg_imageupload:7628:

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • need help in photodetection TIA circuit November 19, 2025
  • Need to solder a really delicate ribbon for an electric reel need advice November 18, 2025
  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 18, 2025
  • Measuring controller current output with a meter November 18, 2025
  • Anyone In The US Ordered From AliExpress Recently? November 17, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

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 | 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