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 / Hello, Firstly,  you didn’t

Hello, Firstly,  you didn’t

|

Microcontroller › PIC › Convert ‘ unsigned long int ‘ to ‘string’ without using inbuilt function for UART › Hello, Firstly,  you didn’t

January 5, 2015 at 9:20 pm #12499
Sasa
Participant

Hello,

 

Firstly,  you didn’t declared buffer in a correct way:

Instead of “unsigned char *t_buffer[8];” use “unsigned char t_buffer[8];”

 

Secondly, you have to fill into t_buffer ascii representation for each digit. There are two ways for do this:

 

1. using sprintf command (header “stdio.h” must be previously included into project) :

sprintf((char*)t_buffer,”%lu”,data0);

2. step by step:

 t_buffer[0] = (data0 / 1000000ul) + 0x30;

data0 /= 1000000ul;

 t_buffer[1] = (data0 / 100000ul) + 0x30;

data0 /= 100000ul;

 t_buffer[2] = (data0 / 10000ul) + 0x30;

data0 /= 10000ul;

 t_buffer[3] = (data0 / 1000ul) + 0x30;

data0 /= 1000ul;

 t_buffer[4] = (data0 / 100ul) + 0x30;

data0 /= 100ul;

 t_buffer[5] = (data0 / 10ul) + 0x30;

 t_buffer[6] = (data0 % 10ul) + 0x30;

 t_buffer[7] = 0;

RSS Recent Posts

  • Battery discharger May 20, 2026
  • Relay question May 19, 2026
  • Phone Charger 5v to 12v May 19, 2026
  • reviving old swordfish program but? May 18, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 18, 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