From e2610ad57d4530c14cb852554ff1638d52d68dd2 Mon Sep 17 00:00:00 2001 From: Jared Sanson Date: Sun, 28 Oct 2018 15:25:37 -0700 Subject: [PATCH] Fix USB priority preventing CAN TX from timing out The blocking CAN implementation relies on SysTick for its timeout. USB had a higher priority than Systick, so the TX never timed out, causing the serial port to hang indefinitely. --- src/usbd_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/usbd_conf.c b/src/usbd_conf.c index 2ba2b83..98309a0 100644 --- a/src/usbd_conf.c +++ b/src/usbd_conf.c @@ -103,7 +103,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) __HAL_RCC_USB_CLK_ENABLE(); /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(USB_IRQn, 0, 0); + // IMPORTANT: USB must have a lower priority than SysTick, or timeouts won't work + HAL_NVIC_SetPriority(USB_IRQn, 1, 0); HAL_NVIC_EnableIRQ(USB_IRQn); /* USER CODE BEGIN USB_MspInit 1 */