11 Replies Latest reply on Dec 18, 2014 6:25 AM by DaKn_263916

    hex to decimal code



      i want hex to dec code

        • 1. Re: hex to decimal code

          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.





          • 2. Re: hex to decimal code

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

            • 3. Re: hex to decimal code

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





              • 4. Re: hex to decimal code

                 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

                • 5. Re: hex to decimal code

                  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?





                  • 6. Re: hex to decimal code

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

                    • 7. Re: hex to decimal code

                      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.,

                      • 8. Re: hex to decimal code

                        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)





                        • 9. Re: hex to decimal code





                            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.





                          • 10. Re: hex to decimal code

                             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 */


                                /* Start the ADC conversion */

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

                                        output = ADC_DelSig_1_GetResult16();
                                                    LCD_Position(1u, 5u);

                            /* [] END OF FILE */


                            • 11. Re: hex to decimal code

                              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.





                              • 12. Re: hex to decimal code

                                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.