Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD
Moderator:
ANCY

Post Reply
Follow this topic



How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

vgy posted on 24 Apr 2013 8:42 AM PST
Top Contributor
133 Forum Posts



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

Bob Marlowe posted on 24 Apr 2013 09:13 AM PST
Top Contributor
1768 Forum Posts

The (my) preferred way to convert a number to a string in ASCII is to use the sprintf() function which allows for a format-specifier to control the conversion.

For a GLCD you will need another conversion that converts the character to a bit-pattern. I could not find an example for a GLCD, but in the software for the FitstTouch - boards is the "PSoC Rocks" program which uses a similar conversion, have a look at it.

 

Bob



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

hli posted on 24 Apr 2013 10:36 AM PST
Top Contributor
675 Forum Posts

What kind of GLCD do you want to use? Do you have already a library for accessing it (can write a string to it already)?



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

vgy posted on 25 Apr 2013 05:07 AM PST
Top Contributor
133 Forum Posts

Is this logic has any logical errors.

int8 i;

uint16  ADC_Sample_Max, decimal, converted_decimal;

while( ADC_Sample_Max !=0 )

{

decimal=[decimal+(ADC_Sample_Max %10)*pow(16,i++)];

ADC_Sample_Max / 10;

}

converted_decimal=decimal;

LCD_Char_1_PrintInt16(converted_decimal);



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

Bob Marlowe posted on 25 Apr 2013 06:45 AM PST
Top Contributor
1768 Forum Posts

Your example does not confirm to C-language standards. I would suggest you to enter your code into PSoC Creator main.c and try to translate it and then correct the errors listed.

To proof the logic behind your code best would be to use a development kit and single-step through the code.

 

A hint: converting a binary number between 0 and 9 into a printable ASCII character is done by oring that byte with 0x30.

 

Bob



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

hli posted on 25 Apr 2013 09:51 AM PST
Top Contributor
675 Forum Posts

LCD_Char_PrintInt16() already prints in hex. If you want to print in decimal, you need to use PrintNumber().

But I thought we are talking about a graphical LCD? Then you should use sprintf() to print the data you need into a character buffer, which you then can convert into something to dispülay on the GLCD (preferrably there is already a library for the LGCD doing the latter).



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

danaaknight posted on 25 Apr 2013 02:08 PM PST
Top Contributor
1773 Forum Posts

The GLCD is compatible with Segger emWin library, which contain

functions for converting chars to write in graphical form to LCD.

 

www.segger.com/emwin.html

 

Regards, Dana.



Re: How to covert Hexadecimal (ADC output) to ASCII and to display on GLCD

hli posted on 26 Apr 2013 10:00 PM PST
Top Contributor
675 Forum Posts

But this assumes the (physical) GLCD is compatible with the GLCD component in Creator...






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20