cancel
Showing results for 
Search instead for 
Did you mean: 

I am using Sensor tile Box in Pro mode and facing issues to setup it to serial communication

AN J.1
Associate

I am exploring Sensor tile Box in pro mode. STM32L4R9ZIJ6 is the controller in it. I tried to display a string using UART pins in the JTAG pin section. While debugging the code was working without any halt. But I didn't got any display in serial console.

I am using STM32cubeIDE for programming the board and Tera Term to display the serial communication. Baud Rate I used is 115200.

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

#include "main.h"

UART_HandleTypeDef huart1;

static void MX_GPIO_Init(void);

void SystemClock_Config(void);

static void MX_USART1_UART_Init(void);

int main(void)

{

 HAL_Init();

MX_GPIO_Init();

 SystemClock_Config();

 MX_USART1_UART_Init();

 while (1)

 {

HAL_UART_Transmit(&huart1, (uint8_t *) "Hello", 10, 1000);

HAL_Delay(1000);

 }

}

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

 if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) != HAL_OK)

 {

  Error_Handler();

 }

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_ON;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 1;

 RCC_OscInitStruct.PLL.PLLN = 30;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

 RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

 RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

  Error_Handler();

 }

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)

 {

  Error_Handler();

 }

 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;

 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

 {

  Error_Handler();

 }

}

static void MX_USART1_UART_Init(void)

{

 huart1.Instance = USART1;

 huart1.Init.BaudRate = 115200;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;

 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

 if (HAL_UART_Init(&huart1) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)

 {

  Error_Handler();

 }

}

static void MX_GPIO_Init(void)

{

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOA_CLK_ENABLE();

 __HAL_RCC_GPIOH_CLK_ENABLE();

}

void Error_Handler(void)

{

 /* USER CODE BEGIN Error_Handler_Debug */

 /* User can add his own implementation to report the HAL error return state */

 __disable_irq();

 while (1)

 {

 }

}

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t *file, uint32_t line)

{

}

#endif /* USE_FULL_ASSERT */

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

I am adding the hardware setup that I am following for both programming the board and UART connection in attached document. I connected Sensor tile Box to JTAG adapter. from JTAG adapter I took TX, RX, GND pins and connect to laptop using USB to UART converter.

Still I am not getting serial data. What can be the reason? Is there any restriction to use UART pins that is used in JTAG section? Can someone help please.

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions
DSull.3
Associate III

Hi, I think you can use directly the USB port of the SensorTile.box.

There is an example for streaming data via USB, it is called DataLogExtended and is in the FP-SNS-STBOX1 package

(https://www.st.com/en/embedded-software/fp-sns-stbox1.html)

Or you might already have resolved your issue...

\Dk

View solution in original post

1 REPLY 1
DSull.3
Associate III

Hi, I think you can use directly the USB port of the SensorTile.box.

There is an example for streaming data via USB, it is called DataLogExtended and is in the FP-SNS-STBOX1 package

(https://www.st.com/en/embedded-software/fp-sns-stbox1.html)

Or you might already have resolved your issue...

\Dk