View previous topic :: View next topic |
Author |
Message |
bigoune
Joined: 19 Oct 2005 Posts: 2
|
Convert binary value to decimal |
Posted: Wed Oct 19, 2005 10:10 am |
|
|
Hi,
I would like to convert binary value to decimal value. Do you know a function in CCS to realize this operation?
Thank you |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Oct 19, 2005 10:21 am |
|
|
Use the Search feature of this forum and write the magic word "BCD", you�ll get
a lot of threads to read and learn how to.
Humberto |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Wed Oct 19, 2005 8:48 pm |
|
|
I would consult the 1st chapter in your introductory course to Digital Logic where they teach binary and decimal. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: Convert binary value to decimal |
Posted: Thu Oct 20, 2005 6:48 am |
|
|
bigoune wrote: | Hi,
I would like to convert binary value to decimal value. Do you know a function in CCS to realize this operation?
Thank you |
Are you saying that you want to convert a string that is a representation of a binary number into an integer? |
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
binary to decimal |
Posted: Thu Oct 20, 2005 8:23 am |
|
|
Hi there I've attached some code done at home for converting the 10 bit binary code from the D to A in the pic to a decimal float. It will display the voltage on an lcd or whatever printf is. I wrote it for a 3volt full scale deflection. e.g 1111111111000000 (65472 in decimal) in long integer value (read from the a to d) represents 3volts... 65472/3 is 21824.
It works ok for me. My maths is not that good though so if there is a problem with it I deny all knowledge ! if it helps, use it
Tim
Code: |
void dis_3v0_fsd(long int value) // Function for sending voltage to LCD, 10 bit, 3.0V FSD.
{
float disval;
disval = value;
disval = disval/21824;
printf(lcd_putc,"%4.2fV",disval);
}
|
_________________ Tim |
|
|
|