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
You are here: Home / Replies / Hi,I’m posting the following

Hi,I’m posting the following

|

Microcontroller › 8051 › gsm module interface › Hi,I’m posting the following

February 18, 2013 at 6:17 pm #9155
AJISH ALFRED
Participant

Hi,

I’m posting the following code just to show you how can we make use of the printf function in microcontroller coding. The uart_print () code has been written for AVR actually, but you can refer the file initialization and the function prototype.

 

//===============================================================//

 

FILE uart_out = FDEV_SETUP_STREAM(uart_print, NULL,
                                         _FDEV_SETUP_WRITE);

int uart_print(char c, FILE *stream)
{
//


this much code is written for avr


//
  if (c == ‘n’)
    uart_print(‘r’, stream);
  loop_until_bit_is_set(UCSRA, UDRE);
  UDR = c;
  return 0;

//


this much code is written for avr


//
}

 

int main ()

{

      unsigned char adc_val;

      usart_init ();

      adc_init ();

 

      adc_val = adc_get ();

 

      stdout = &uart_out;    

      printf ( “nTemp:%d C”, adc_val );        

}

//===============================================================//

 

Hope this helps you.

    

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 11, 2022
  • uc3843 Buck-boost August 11, 2022
  • Drill speed controller fault August 11, 2022
  • Code suggestion from Android Studio. Good? August 11, 2022
  • Nokia 5110 HW in Oshonsoft August 11, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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