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 / please help me to find error in this code

please help me to find error in this code

|

Microcontroller › AVR › please help me to find error in this code

  • This topic has 0 replies, 1 voice, and was last updated 12 years, 4 months ago by sachin waghmode.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • March 9, 2013 at 5:47 am #2173
    sachin waghmode
    Participant

     

    its not showing anything on hyperterminal

    #include <avr/io.h>
    #include <avr/delay.h>
    #define F_CPU 12000000UL
    #define USART_BAUDRATE 9600
    #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) – 1)
    void usart_init();
    void usart_putch(unsigned char send);
    unsigned int usart_getch();
    unsigned char value;
    int main(void)
    {
        usart_init();    // initialization of USART
        value=usart_getch();    // get data from serial port
        usart_putch(value);    // 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
        UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value..
        // into the low byte of the UBRR register
        UBRRH = (BAUD_PRESCALE >> 8); // 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))); // Do nothing until UDR is ready..
        // for more data to be written to it

        UDR = send; // Send the byte
        return 0;
    }

    unsigned int usart_getch()
    {
        while (!(UCSRA & (1 << RXC)));
        // Do nothing until data have been received and is ready to be read from UDR
        
        return(UDR); // return the byte
    }

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

RSS Recent Posts

  • Fixing board, Easy question HEX SCHMITT July 10, 2025
  • Can I make two inputs from one?? July 10, 2025
  • Display TFT ST7789 (OshonSoft Basic). July 9, 2025
  • Home Smoke detectors are all Beeping Batteries are not dead.??? July 9, 2025
  • The Analog Gods Hate Me July 9, 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