UART Data

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
OsFe_2822791
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

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.

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA
2 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Could you take a loot at my old memo?

printf and float rhapsody (aka, yet another printf and floating topic)

moto

Thank you for your response.

My problem was an incorrect Heap Syze that you comment in the second case in your explanation.

Thank you very much.

Best regards.