USART1 interrupt handler not called
Hello,
first, I'm new to STM32 Nucleo MCUs, so if I am asking something that is well-known in documentation of Nucelo boards please advise me to correct documentation.
I have a project using a STM32 L432KC that gets serial data from another MCU and sendsdata iuzt via CAN and UART2.
The project is configured with using UART interrupt mode (on both UART1/2). If I check serial data without connected STM32, the data is correctly send from other MCU (configured with baud rate 115200) and also on STM side UART1 is configured with 115200 baud rate:
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
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.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
UART1 is configured to output pins PA9 (Serial1 TX) and PA10 (Serial1 RX), both connected to serial output from other MCU. If I check without STM MCU, all data is correctly sent from this MCU (as I can check with serial terminal connection). But as soon as I connect with STM, serial data flow stops from other MCU, no other data is seen if I connect serial cable to pins PA9/10 mentioned above.
For init of STM HAL functions are used as documented with normal interrupt mode for UART1:
int main(void)
{
/* USER CODE BEGIN 1 */
HAL_DeInit();
/* 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_USART2_UART_Init();
MX_CAN1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
...
//Activate UART interrupt
HAL_UART_Receive_IT(&huart1, RxData, sizeof(RxData));
...
and in RxCallback function several checks for incoming data are made:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) //if STM32 receives Data
{
HAL_UART_Receive_IT(&huart1, RxData, sizeof(RxData));
if (RxData[2] == 0x37) {
if (RxData[3] == 0x37) {
reset = 1;
return;
}
}
if (RxData[0] == '0')
{
return;
}
printf("%d%d\r\n", RxData[0], RxData[1]);
if (isCMD(RxData)) transmit = 1;
}
If I debug STM code and trigger data transmit from other MCU, the RxCallback function never gets triggered, so my question is, am I doing something wrong?
Note: I'm using CubeIDE 1.13.0
Thanks for any hints & suggestions,
Lorky