UART RX interrupt
Hello,
I'm trying trying to setup an interrupt receive on the U5 MCU using the STM32U5GJ-DK2 development kit. The USART1_IRQHandler does not get triggered at all. Here's my CubeMX config for the USART1:


I've sniffed the RX line, so I'm sure it's working as expected.
Here's my main() code:
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();
/* Configure the System Power */
SystemPower_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_GPDMA1_Init();
MX_ICACHE_Init();
MX_DCACHE1_Init();
MX_DCACHE2_Init();
MX_CRC_Init();
MX_LTDC_Init();
MX_DMA2D_Init();
MX_GPU2D_Init();
MX_HSPI1_Init();
MX_I2C2_Init();
MX_JPEG_Init();
MX_USART1_UART_Init();
// MX_TouchGFX_Init();
/* Call PreOsInit function */
// MX_TouchGFX_PreOSInit();
/* USER CODE BEGIN 2 */
HAL_UARTEx_ReceiveToIdle_IT(&huart1, RxBuffer, RxBuffer_Size);
__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
printf("OS kernel initialized\n");
/* USER CODE END 2 */
/* Init scheduler */
// osKernelInitialize();
/* Call init function for freertos objects (in freertos.c) */
// MX_FREERTOS_Init();
/* Start scheduler */
// osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
and here's my redefined Callback as per the HAL's instructions:
int len = 0;
#define RxBuffer_Size 20
#define TxBuffer_Size 20
uint8_t RxBuffer[RxBuffer_Size];
uint8_t TxBuffer[TxBuffer_Size];
extern uint8_t ComCommand[RxBuffer_Size];
extern uint8_t polled;
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
if (huart->Instance == USART1)
{
memset(ComCommand, 0, sizeof(ComCommand));
len = strlen(RxBuffer);
strncpy(TxBuffer, RxBuffer, len);
strncpy(ComCommand, RxBuffer, len);
polled = 0;
// HAL_UART_Transmit(&huart1,TxBuffer,len,HAL_MAX_DELAY); //transmit the full sentence again
memset(TxBuffer, 0, sizeof(TxBuffer));
memset(RxBuffer, 0, sizeof(RxBuffer));
printf("UART transfer complete\n");
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, RxBuffer, RxBuffer_Size);
__HAL_DMA_DISABLE_IT(&hdma_usart1_rx, DMA_IT_HT);
}
}
I've been using the same technique on the f7, where it was working flawlessly, but on the u5 the interrupt never gets triggered, so the callback never gets called. What am I missing?
