AnsweredAssumed Answered

STM32F303re USB/CAN shared interrupts and CAN transmission timeout

Question asked by David Pekin on Dec 27, 2017

Hello,

 

I'm trying to get CAN up and running on a STM32f303re.  I've ported the CAN Networking sample over from the STM32373C eval board sample sources to the STM32f303re.  It is starting to work as I can send a packet and it appears to get to the 2nd STM32 across the physical CAN bus based on looking at the TX and RX lines on the 2 devices but it never seems to trigger the CAN TX or RX interrupts.  I see that the 303 has different interrupts than the eval board processor.  I've tried to map them correctly but so far have had no luck.   

 

So, even though the packet gets transmitted across the physical layer, I am getting a timeout error in the HAL_CAN_Transmit(...) function below:

 

/* Request transmission */
SET_BIT(hcan->Instance->sTxMailBox[transmitmailbox].TIR, CAN_TI0R_TXRQ);

/* Get tick */
tickstart = HAL_GetTick();

/* Check End of transmission flag */
while(!(__HAL_CAN_TRANSMIT_STATUS(hcan, transmitmailbox)))
{
/* Check for the Timeout */
if(Timeout != HAL_MAX_DELAY)
{
if((Timeout == 0U) || ((HAL_GetTick()-tickstart) > Timeout))
{
hcan->State = HAL_CAN_STATE_TIMEOUT;

/* Cancel transmission */
__HAL_CAN_CANCEL_TRANSMIT(hcan, transmitmailbox);

/* Process unlocked */
__HAL_UNLOCK(hcan);
return HAL_TIMEOUT;        // getting this timeout
}
HAL_Delay(1);
}
}

 

I would assume that this is because the TX interrupt is not getting called and it's not indicating that the transmission is complete.  Has anyone succeeded at getting CAN working on the STM32F303re? Any pointers on setting up the interrupts?

 

Thanks for any suggestions.

Outcomes