You are here

Displaying a float number on LCD | Cypress Semiconductor

Displaying a float number on LCD

Summary: 3 Replies, Latest post by Danyi on 04 Oct 2016 12:22 PM PDT
Verified Answers: 1
Last post
Log in to post new comments.
Danyi's picture
User
5 posts

Hi,

My project is to display, in different formats, the results of the A/D conversion. I cannot display the result in decimal format (floating point).

My resources are:

PSOC Creator 3.3.

PSOC4: CY8CKIT-049-42XX-(CY8C4245AX483)

LCD: RC1602B

​I wrote the ”-u_printf_float”  as a custom command line for the Linker tool.

The LCD is displaying only ”ADC”, at position (0,0).

Thank You!

The main file is bellow:

#include <project.h>
#include <stdio.h>
int main()

    int32 conversie;
    char cuvant [16];
    float32 val,vin ;
    
    CyGlobalIntEnable; /* Enable global interrupts. */
    ADC_Start();
    ADC_StartConvert();
    ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
    
    LCD_Start();
    LCD_Position(0,0);
    LCD_PrintString("ADC");
       
    for(;;)
    { 
    conversie = ADC_GetResult16(0);
    val = ADC_CountsTo_Volts(0,conversie);    
    sprintf(cuvant,"%1.4f       ",val);
    LCD_Position(1,0);
    LCD_PrintString(cuvant);
   
    
    vin = (float32)conversie * 1024/32768;
    sprintf(cuvant,"%1.3f       ",vin);
    LCD_Position(1,6);
    LCD_PrintString(cuvant);
   
   
    
    LCD_Position(0,6);  
    LCD_PrintNumber(vin);
    
    LCD_Position(0,10);
    LCD_PrintInt16(conversie);
    
    LCD_Position(1,11);
    LCD_PrintInt16(vin);
    
      
    CyDelay(1000);
    }
}

/* [] END OF FILE */

HIMA's picture
Cypress Employee
320 posts

Hello,

Can you increase the stack size inn .cydr->System_>Stack Size.

 

Thanks,

Hima

user_1377889's picture
User
10106 posts

It is not the stack size, but the heap size. Set it to at least 0x0200.

 

Bob

Danyi's picture
User
5 posts

Thanks for both, Bob(0x0200) and Hima(0x0800).
IT is working now.

Log in to post new comments.