In the unified_bootloader_demo program. In interrupt, the program passes the received data into the TP layer before calling CAN_Receive. I'm not sure if this makes sense because the data coming into the TP layer is the same data that was received in the last interrupt. Should we swap CAN_Receive and TP_DriverWriteDataInTP sequentially
void CAN_ISR_Callback(uint32_t instance,
can_event_t eventType,
uint32_t objIdx,
void *driverState)
{
if(CAN_EVENT_RX_COMPLETE == eventType)
{
TP_DriverWriteDataInTP(g_RXCANMsg.id, g_RXCANMsg.length, g_RXCANMsg.data);
CAN_Receive(&can_pal1_instance, 1, &g_RXCANMsg);
}
else if(CAN_EVENT_TX_COMPLETE == eventType)
{
TP_DoTxMsgSuccesfulCallback();
}
else
{}
}
解決済! 解決策の投稿を見る。
Hi,
it is correct usage this way. CAN_Receive was called at beginning and within ISR/callback a g_RXCANMsg contains received data, so it is passed to higher layer. Then CAN_Receive is called to start receiving again. In fact it reenables MB interrupt and update internal status variable.
BR, Petr
Hi,
it is correct usage this way. CAN_Receive was called at beginning and within ISR/callback a g_RXCANMsg contains received data, so it is passed to higher layer. Then CAN_Receive is called to start receiving again. In fact it reenables MB interrupt and update internal status variable.
BR, Petr
Thanks for your answer, I seem to have a little misunderstanding about the function of CAN_Receive. When a program starts calling CAN_Receive, it seems to be ready to receive data, rather than necessarily calling CAN_Receive when it wants to receive data. Am I getting this right? It seems I need to know more about the mechanism of CAN_Receive
Hi,
in fact FlexCAN module is able to receive message after CAN_ConfigRxBuff is called. This will prepare the selected MB to accept message with defined ID. A CAN_Receive then update driver's status variable and enable MB interrupt. Once message is received interrupt is called, data moved into given user buffer, MB interrupt disabled, driver's status variable updated and callback called. Within callback user process es data in user buffer and call CAN_Receive again to enable MB interrupt etc.
Ideally CAN_Receive should be called before each message will come.
BR, Petr