Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > Ok I am stumped completly Displaying results

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



Ok I am stumped completly Displaying results
Moderator:
RKRM

Post Reply
Follow this topic



Ok I am stumped completly Displaying results

pnielsen3 posted on 29 Mar 2013 10:15 AM PST
Top Contributor
107 Forum Posts

 

The code below will print numbers like 3BB1, 120F. I can't get the diplay to read decimal value like 5051 with no letters. I think I tried everything. I used LCD_Char_PrintNumber(HYT221_Read_Buff[1]); I tried sprintf.  What is it that I am missing?

Philip

 

 

uint8 HYT221_Read_Buff[4] = {0};

uint8 HYT221_Write_Buff[4] = {0};

 

void Display_Result(void)

{

LCD_Char_Position(0,6);

 

LCD_Char_PrintInt8(HYT221_Read_Buff[0] & 0x3f); //Mask HYT humidity the highest two status bits

LCD_Char_PrintInt8(HYT221_Read_Buff[1]);

//    LCD_Char_PrintNumber( HYT221_Read_Buff[1]); 

// void LCD_Char_PrintNumber(uint16 value) ; 

// duty1_string=(HYT221_Read_Buff);

sprintf(HYT221_Read_Buff,CharLCD_PrintNumber(HYT221_Read_Buff);

// sprintf (duty1_string, "%2.2f", duty1);

// LCD_Char_Position(0,6);

 //   CharLCD_1_PrintString(duty1_string);

 

// LCD_Char_PrintNumber(HYT221_Read_Buff[1]);

LCD_Char_PrintString("      ");

LCD_Char_Position(1,6);

    LCD_Char_PrintInt8(HYT221_Read_Buff[2]);

LCD_Char_PrintInt8(HYT221_Read_Buff[3] & 0xfc); //Mask HYT temperature the lowest two status bits

    LCD_Char_PrintString("      ");

}




Re: Ok I am stumped completly Displaying results

Bob Marlowe posted on 29 Mar 2013 11:08 AM PST
Top Contributor
1768 Forum Posts

sprintf() should have worked, PrintInt8() or 16 are printing Hex-numbers, have a look into datasheet.

Best would be to use LCD_PrintNumber(), but this expects an int16, so better cast your value into an int16

 

Bob



Re: Ok I am stumped completly Displaying results

Bob Marlowe posted on 29 Mar 2013 11:46 AM PST
Top Contributor
1768 Forum Posts

... and as I just see, you enabled in the UART> the command buffer which you cut off with the LJMP to your ISR. Disable the buffer to save some space in flash and ram.

 

Mean Bob



Re: Ok I am stumped completly Displaying results

Bob Marlowe posted on 29 Mar 2013 11:48 AM PST
Top Contributor
1768 Forum Posts

Oops, sorry, this is the wrong thread. I'll take another try...

 

Bob



Re: Ok I am stumped completly Displaying results

H L posted on 29 Mar 2013 05:50 PM PST
Top Contributor
679 Forum Posts

Do you want to print 256 on the screen if the value of the higher byte is  0x01 and the lower byte is 0x00?

If that is the case, try this

uchar ucData1digit;

uchar ucData10digit,

uchar ucData100digit,

uchar ucData1000digit,

uchar ucData10000digit,

 

uint uiData = (a[1] << 8) + a[0];

ucData1digit = uiData %10;

ucData= uiData / 10;

ucData10digit = uiData %10;

ucData= uiData / 10;

.....

/* after getting the 5 number, print the on the LCD starting with ucData10000digit first .......*/

/* you can do leading 0 blanking as well */

 

 




Re: Ok I am stumped completly Displaying results

H L posted on 29 Mar 2013 05:57 PM PST
Top Contributor
679 Forum Posts

 or you can try 

/* a[1] is the higher bute */

uint16 uiData = a[1] & 0x3f;

uiData <<= 8;

uiData += a[0]; 

LCD_Char_PrintNumber(uiData);



Re: Ok I am stumped completly Displaying results

danaaknight posted on 30 Mar 2013 03:27 AM PST
Top Contributor
1773 Forum Posts

sprintf() has many formatting capabilities that may be useful. Its only

downside is the library code added is significant.

 

Attached some formatting strings that make sprintf() really nice way of

converting numbers into text strings to print with LCD print string API.

 

Regards, Dana.



Re: Ok I am stumped completly Displaying results

pnielsen3 posted on 01 Apr 2013 07:25 AM PST
Top Contributor
107 Forum Posts

Bob,

 

     I just recast my unit8 to unit16. I will see if this will work. Do you know if there is any book or notes about C from Cypress for the PSOC3 and PSOC5 family. The Designer included a help tab with a compiler section. This was great. I moved two years ago and lost mt C code book.

 

Thanks Bob I will give it a try.

 

Philip



Re: Ok I am stumped completly Displaying results

Bob Marlowe posted on 01 Apr 2013 08:02 AM PST
Top Contributor
1768 Forum Posts

The few special things for PSoCs are to be found in the corresponding compiler manuals, the System Reference Guide (under Help-tab of Creator) and the datasheets of the user-modules.

For a C-redference I use http://publications.gbdirect.co.uk/c_book/

 

Bob






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