question about unified bootloader demo intrrupt Receiving

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

question about unified bootloader demo intrrupt Receiving

跳至解决方案
842 次查看
Huan89898989
Contributor I

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
	{}
}

 

0 项奖励
回复
1 解答
815 次查看
PetrS
NXP TechSupport
NXP TechSupport

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

在原帖中查看解决方案

4 回复数
816 次查看
PetrS
NXP TechSupport
NXP TechSupport

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

812 次查看
Huan89898989
Contributor I

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

0 项奖励
回复
793 次查看
PetrS
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复
782 次查看
Huan89898989
Contributor I
Thanks Petr, I think I have understood the part about CAN_Receive opening interrupts, so the logic of the program should flow smoothly
0 项奖励
回复