Correct way to send CAN message inside interrupt
I'm using an STM32F4 Discovery and an MCP2562 transceiver. I have CAN working using the CAN2 port.
In my implementation, I'm sending several CAN messages inside a timer interrupt. I'm using the HAL function HAL_CAN_TRANSMIT_IT. It works fine until I try to send 3 or more messages in a row, in that case HAL_CAN_TRANSMIT_IT returns an error. How should I work around this?
I thought about using HAL_CAN_TRANSMIT, which has the option to use a timeout, but since this is called inside an interrupt, this should be avoided.
Any help will be greatly appreciated.
#hal #can #stm32f4-discovery