question about unified bootloader demo intrrupt Receiving

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

question about unified bootloader demo intrrupt Receiving

Jump to solution
840 Views
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 Kudos
Reply
1 Solution
813 Views
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

View solution in original post

4 Replies
814 Views
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

810 Views
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 Kudos
Reply
791 Views
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 Kudos
Reply
780 Views
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 Kudos
Reply