I want to able to send my ADC values to a Nodemcu to put them a Web UI but I even could not send any UART value to a serial port and I did not catch the problem.
I set my variables and libs like:
#include "stdio.h"
#include "string.h"
uint8_t convEnd = 0;
uint32_t adcBuff[3];
uint32_t adcData[3];
After this, I read my ADC values by using DMA Method, I set a flag to turn 1 when the conversion done.
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
if (hadc->Instance == ADC1) {
adcData[0] = adcBuff[0];
adcData[1] = adcBuff[1];
adcData[2] = adcBuff[2];
convEnd = 1;
}
}
Next, I started DMA and put this code to my while (1)
loop,
while (1) {
if (convEnd == 1) { // check is conv completed
char txt[30];
sprintf(txt, "ADC Val: %d %d\n\r", adcData[0], adcData[1]);
HAL_UART_Transmit(&huart2, (uint8_t *)txt, strlen(txt), 100);
HAL_Delay(500);
convEnd = 0;
}
}
As a result, I can read ADC correctly but I can not send these values via UART to any Serial Port.