cancel
Showing results for 
Search instead for 
Did you mean: 

ADC USART Tera Term

MFara.4
Associate III

I use this code to get the data ADC and transmit it but I can't see my data on Tera Term, I see my data in live Expression but not in Tera Term so most probably problem comes from Transmit part!! I would be happy if you take a look at the code that which part might be wrong.(STMG01291)

ADC1 - IN9 (tick)

Parameter Settings --> ADC Settings --> Continuous Conversion Mode (Enabled)

Enable USART1 asynchronous

Parameter Settings --> Basic Parameters --> Baud rate 9600

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_ADC1_Init(void);

static void MX_USART1_UART_Init(void);

/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

uint16_t readValue;

char string[10];

/* USER CODE END 0 */

/**

 * @brief The application entry point.

 * @retval int

 */

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_ADC1_Init();

 MX_USART1_UART_Init();

 /* USER CODE BEGIN 2 */

 HAL_ADC_Start(&hadc1);

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

 HAL_ADC_PollForConversion(&hadc1,1000);

 readValue = HAL_ADC_GetValue(&hadc1);

 HAL_UART_Transmit(&huart1, (uint8_t *)&readValue, sizeof(readValue), 100);

2 REPLIES 2
gbm
Lead III
  1. What's the hardware used?
  2. TeraTerm displays text characters. You are sending binary data, which may result in some random characters displayed or commands executed by TeraTerm. You need to convert the data using something like sprintf(), then sent the resulting text via UART.
My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
RomainR.
ST Employee

Duplicated questions with:

https://community.st.com/s/topic/0TO0X000000BSqSWAW/stm32-mcus#:~:text=STM32%20MCUs-,Stm32%20to%20Python,-Like

BR

Romain

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.