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 / thanks Sasa.. ur post

thanks Sasa.. ur post

|

Microcontroller › PIC › Convert ‘ unsigned long int ‘ to ‘string’ without using inbuilt function for UART › thanks Sasa.. ur post

January 7, 2015 at 10:50 am #12500
Jayant Gupta
Participant

thanks Sasa.. ur post provided me a lot of help and i implemented it sucessfully

i had to make certain small changes to get it working .. i really appreciate ur help without it would have been lil difficult understanding further step.

 

i am posting the code here jus incase someone might need it.

 

void convert_l2s(unsigned long int data0, unsigned char temp_buffer[8])
{
    temp_buffer[0]=(data0/1000000)+0x30;
    data0%=1000000;
    UART_Write_Byte(temp_buffer[0]);
    temp_buffer[1]=(data0/100000)+0x30;
    data0%=100000;
    UART_Write_Byte(temp_buffer[1]);
    temp_buffer[2]=(data0/10000)+0x30;
    data0%=10000;
    UART_Write_Byte(temp_buffer[2]);
    temp_buffer[3]=(data0/1000)+0x30;
    data0%=1000;
    UART_Write_Byte(temp_buffer[3]);
    temp_buffer[4]=(data0/100)+0x30;
    data0%=100;
    UART_Write_Byte(temp_buffer[4]);
    temp_buffer[5]=(data0/10)+0x30;
    UART_Write_Byte(temp_buffer[5]);
    temp_buffer[6]=(data0%10)+0x30;
    UART_Write_Byte(temp_buffer[6]);
    temp_buffer[7]=0;
    UART_Write_Byte(temp_buffer[7]);
}

 

i am trying to generalize it using loop for n digits int type!!

 

do i need to use a similar approach for float data as well???

RSS Recent Posts

  • using a RTC in SF basic June 21, 2025
  • Can I make two inputs from one?? June 21, 2025
  • Help with finding unique wire lug(s) June 21, 2025
  • Simple LED Analog Clock Idea June 21, 2025
  • Kawai KDP 80 Electronic Piano Dead June 21, 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