hex to decimal code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 hi

   

i want hex to dec code

0 Likes
12 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A two-minute solution would be to #include <stdio.h> and to use csprintf(Buffer,"%d",Hexvalue);

   

Buffer must be declared as char [nnn] big enough to hold the characters plus a terminating null-character.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 now i want multiply with 60 and i want decimal value ?how bob?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Will  csprintf(Buffer,"%d",Hexvalue * 60u); fit your needs?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 thanks bob

   

my doubt is 

   

i got decimal value for sec i.e rps->     eg.1000,5000 like this

   

now i want rpm for those decimal value in decimal manner

   

plz help

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

first pitfall could be 5000 * 60 > 32767 which means you cannot use an int to hold the result.

   

So you have to use a long variable to hold the result of the multiplication.

   

Next question: What do you want to do with the result?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 for finding rpm and displays it in hyperterminal or LCD , i want hex to dec 

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Use sprintf(), arguments for formatting attached. sprintf()

   

will convert numeric to formatted character string, in LCD

   

datasheet is an API to print a character buffer to LCD.

   

 

   

LCD_PrString(CHAR * sRamString);

   

 

   

Regards, Dana.,

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just for the vocabular: you do not need a hex-to-dec conversion but an int-to-ASCII conversion.

   

ASCII characters represent human readable characters (and a few control chars)

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Bob,

   

 

   

  I wanted to make sure I thanked you for your help. I was going nuts. My compiler at work was able to compile. But my PC at home will not compile properly. I will fix that problem tonight. Any way I just wanted to say may thanks for your help.

   

 

   

Philip

0 Likes
Anonymous
Not applicable

 hai. i want to changed the  adc value from hexa decimal to decimal, i am using a PSoC microcontroller. software is PSoC creator 2.1 k. Help me to convert the value.

   

My code is follow...

   


void main()
{
    uint16 output;
    uint16 output1;

    /* Start the components */

    LCD_Start();
    ADC_DelSig_1_Start();

    /* Start the ADC conversion */
    ADC_DelSig_1_StartConvert();

    /* Display the value of ADC output on LCD */
    LCD_Position(0u, 0u);
    LCD_PrintString("ADC_Output");

    for(;;)
    {
        if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS))
        {
            output = ADC_DelSig_1_GetResult16();
                        LCD_Position(1u, 5u);
            LCD_PrintNumber(output);
        }
    }
}


/* [] END OF FILE */

 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum!

   

A couple of suggestions:

   

Upgrade Creator to 3.0, the version 3.1 will come out shortly and it might be that a project update from version 2 to 3.1 is not possible.

   

Your main-loop is running very fast, you will not be able to see changes on the LCD. Best is to put a CyDelay() into the loop or to set up a timer, so that you update the LCD not more often than 10 times a second. CyDelay description to be found in "System Reference Guide" under the Help-menu -> Documentation ...

   

Clear the display by writing a string with spaces before writing a new value. The new value may have lesser digits, so you won't see the correct result.

   

And lastly: You posted in a PSoC1 forum and you are obviously using a PSoC3, 4 or 5. So some of us will not look at this (rather old) thread to find your question.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

One way around the delay problem, the waste of MIPS sitting in a loop that

   

does nothing, is to create in RAM a display buffer. So for example if your display

   

is 2 x 16, then a 2 x 16 array. Then when you want to update display, you first

   

check buffer for any character change from the new display data. If a character has

   

changed write that char to display, and update buffer. If no change do nothing. This

   

way you can be in a main( ) loop of any speed, and it will create a clean looking

   

display with no artifacts. You only change what you have to when you have to.

   

Eliminates display artifacts due to repeated fast writes

   

 

   

Regards, Dana.

0 Likes