Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting 24 bit numbers into BCD for 7 segment displays

Status
Not open for further replies.

mikoyan

New Member
hi guys,

I'm looking for some advice. I'm using a PIC18F452 device and C language.

Basically, I have a 24 bit number that I need to output from the device, I've elected to use the standard I/O ports as I want my device to stand alone - i.e. not using the ascII option to hyperterminal.

I'm guessing the correct thing to do is to convert the binary value into BCD first, then break down the BCD number somehow (arrays) so that they can be put on the various port output lines... the execution of this is bugging me slightly, I'm not so good with C syntax (have been using FPGAs of late, only recently decided to have a go with PICs)

any advice is greatly appreciated.
 
BoostC has sprintf, sprintf32 and an integer to decimal function. All populate an array which I then squirt at the lcd one by one. Perhaps your compiler has something similar. You will need to break your 24bit numbers into two for some of these to work.
David.
 
Use a char variable for each 7-segment. If the number is 120, bitwise operators will split it into 3 chars with values 1, 2, and 0. Then output whatever code displays 1, 2, and 0 to a multiplexed display. Only 7 bits are needed.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top