When CANBUS interrupt is activated, then USB connection does not work - Help with priorities
Hi!
I don't know really how to explain this. But I have enabled CANBUS and it works very good. I also have activated USB and it works too.
But since I have changed the preemption from 0 to 1 for CANBUS RX0, I have no ability to use USB connection.
I changed the preemption from 0 to 1 for CANBUS RX0 because else SysTick would stop. HAL_GetTick() gave the same number for ever as long I was inside the CANBUS RX interrupt function.
What happen when I have 1 for CANBUS RX0 in priority and plug in the USB. From my computers perspective, it says that it could not connect the device.
From my STM32 perspective, I get stuck inside this while loop for ever where wIstr = 41465
/**
* @brief This function handles PCD Endpoint interrupt request.
* @param hpcd PCD handle
* @retval HAL status
*/
static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd)
{
PCD_EPTypeDef *ep;
uint16_t count, wIstr, wEPVal, TxByteNbre;
uint8_t epindex;
/* stay in loop while pending interrupts */
while ((hpcd->Instance->ISTR & USB_ISTR_CTR) != 0U)
{
wIstr = hpcd->Instance->ISTR;
/* extract highest priority endpoint number */
epindex = (uint8_t)(wIstr & USB_ISTR_EP_ID);
if (epindex == 0U)I activate the CANBUS interrupt with this code. I'm trying out the J1939 CANBUS library https://github.com/DanielMartensson/Open-SAE-J1939
/* Interrupt handler that read message */
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
Open_SAE_J1939_Listen_For_Messages(j1939_handler);
}
static void Create_CAN_Interrupt(CAN_HandleTypeDef *hcan) {
/* Don't forget to check NVIC in CAN -> NVIC Settings -> CAN RX0 interrupt */
if (HAL_CAN_ActivateNotification(hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
Error_Handler();
}Question:
What I acctully want help with is that HAL_GetTick() did not work with CANBUS RX0 priority 0, so I changed the priority to 1. So now HAL_GetTick() works inside the CANBUS RX interrupt function above.
But then USB won't work because I cannot connect it if the CANBUS RX0 priority is 1. So I need to set it to 0 again, but then I'm facing the same issue as before.
So what should I do here?
- Should I remove the HAL_GetTick() function from my CANBUS RX0 interrupt function and change the priority from 1 to 0 again?
- Should I change the priority for USB? (I have tried that, did not work)
- Should I change SysTick to a timer? Because HAL_GetTick() using SysTick...I assume that.
- Other solutions?
What do you think?
My STM32 is STM32F373VBTx and I'm using STM32CubeIDE 1.7.0.
