2025-08-10 9:18 AM - last edited on 2025-08-21 7:27 AM by mƎALLEm
Hello,
I’m working on a project with an STM32F446RE where I read data from a CAN bus at 500 kbps (CAN1_RX0) and also use I2C to control an MCP4725 DAC, plus timers and DMA for other tasks.
The problem:
When I test CAN alone, it works perfectly — I can receive all messages from my device (a motorcycle inverter).
When I run the full code with all peripherals connected and active (CAN + I2C + TIM2 + DMA), the CAN stops receiving after a short time, or doesn’t receive at all.
On the motorcycle, this happens consistently, but on the bench with CAN only, it works fine.
What I tried so far:
Set CAN NVIC priority higher than other interrupts:
Reduced I2C timeout to avoid blocking (HAL_I2C_Master_Transmit with 2 ms instead of HAL_MAX_DELAY).
Tried opening the CAN filter (mask = 0) to receive all IDs for debugging.
Enabled HAL_CAN_ErrorCallback
Despite all these changes, when all peripherals are running in the motorcycle environment, CAN stops working (no messages received) while I2C and timers keep running.
My questions:
Could this still be an interrupt priority problem?
Is there something else that could block CAN reception without triggering Bus-Off or errors?
Any advice or similar experience would be appreciated.
I have attached my main code
Thank you.
Solved! Go to Solution.
2025-08-21 11:22 AM
Your code shows you are using ADC and you mention all the other peripherals but it. You haven't attached your stm32xxx_hal_msp.c file so don't know if the ADC is using DMA in circular mode?
In a project I was working on, I had issues having ContinuousConvMode enabled in that the ADC was always interrupting and certain interrupts would not interrupt. I disabled it and I just used a timer to start the ADC conversion periodically. Try disabling the ContinuousConvMode and see if it makes a difference.
2025-08-21 7:25 AM
Hello,
You said:
@Soniaa12 wrote:
When I test CAN alone, it works perfectly
Then you said:
@Soniaa12 wrote:
Is there something else that could block CAN reception without triggering Bus-Off or errors?
Are you sure CAN is working well for a long time when it is alone?. I don't think Bus-Off is something linked to adding more modules but to something in the HW or software linked to the CAN itself.
2025-08-21 11:22 AM
Your code shows you are using ADC and you mention all the other peripherals but it. You haven't attached your stm32xxx_hal_msp.c file so don't know if the ADC is using DMA in circular mode?
In a project I was working on, I had issues having ContinuousConvMode enabled in that the ADC was always interrupting and certain interrupts would not interrupt. I disabled it and I just used a timer to start the ADC conversion periodically. Try disabling the ContinuousConvMode and see if it makes a difference.