2 Replies Latest reply on Jul 5, 2020 12:21 PM by OsFe_2822791

    UART Data

    OsFe_2822791

      Hi everyone!

      I am creating a script to read a voltage from an analog pin and show the value by UART. I am using this code:

      ----------------------------------

      #include <project.h>

      #include <stdio.h>

      int main()

      {

      int32 temp;

      int16 ADCResultado;

      float32 ADCVoltaje;

      char str[30];

      UART_Start();

      UART_UartPutChar(12);

      UART_UartPutString("Conversor AD:");

      UART_UartPutCRLF(0u);

      ADC_Start();

      for(;;)

      {

      ADC_EnableInjection();

      ADC_StartConvert();

      ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

      ADCResultado=ADC_GetResult16(1);

      ADCVoltaje=ADC_CountsTo_Volts(0,ADCResultado);

      sprintf(str,"Voltaje: %.4f V",ADCVoltaje);

      UART_UartPutString(str);

      UART_UartPutCRLF(0u);

      CyDelay(500);

      }

      }

      -----------------------------------

      The problem is I obtain this in UART: "Voltaje: V" and there are 5V in pin 2.0 (which I attached correctly). Can you help me?

      Many thanks.