3 Replies Latest reply on Oct 4, 2016 10:47 AM by hima

    Displaying a float number on LCD

    daniel.plescan

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