Skip to main content
MFara.4
Associate III
December 13, 2022
Question

ADC USART Tera Term

  • December 13, 2022
  • 2 replies
  • 1064 views

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);

This topic has been closed for replies.

2 replies

gbm
Lead III
December 13, 2022
  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
December 13, 2022
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.