mpc5777c flexcan TX and RX interrupt callback function

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

mpc5777c flexcan TX and RX interrupt callback function

904 Views
Krishnayya
Contributor I

Hello all,

I am using flexcan processor generated code to generate interrupt for both RX and TX.but the problem i am facing is when i tried use both Rx and tx callbacks simultaneously only tx is working fine and  when i do it separately both are working properly.could  anyone please guide what i am doing wrong in using tx and rx callbacks and how to disable the callbacks once they served.

code is as below.

FLEXCAN_DRV_Init(INST_CAN_A, &can_A_State, &can_A_InitConfig0);

flexcan_data_info_t txInfo = { .msg_id_type = FLEXCAN_MSG_ID_STD,
.data_length = ((uint8_t) 8U), .is_remote = false };
FLEXCAN_DRV_ConfigTxMb(INST_CAN_A, 15, &txInfo, 0x2F2);
FLEXCAN_DRV_ConfigRxMb(INST_CAN_A, 14, &txInfo1, 0x301);
FLEXCAN_DRV_SetRxMaskType(INST_CAN_A, FLEXCAN_RX_MASK_INDIVIDUAL);
FLEXCAN_DRV_SetRxIndividualMask(INST_CAN_A, FLEXCAN_MSG_ID_STD, 14,
0xFFFFFFFF);
FLEXCAN_DRV_InstallEventCallback(INST_CAN_A, CAN_A_EventCallBack,
(void *) 0);
FLEXCAN_DRV_Receive(INST_CAN_A, 14, &CAN_A_RX_Buffer);
FLEXCAN_DRV_Receive(INST_CAN_A, 14, &CAN_A_TX_Buffer);
FLEXCAN_DRV_InstallEventCallback(INST_CAN_A, CAN_A_TX_EventCallBack,
(void *) 0);

---------------------------------------------------------------------

void CAN_A_TX_EventCallBack(uint8_t instance, flexcan_event_type_t eventType,
uint32_t buffIdx, flexcan_state_t *flexcanState) {
if (eventType == FLEXCAN_EVENT_TX_COMPLETE) {
CAN_A_TX_Complete();
return;
}

}

------------------------------------------------------------------------


void CAN_A_RX_EventCallBack(uint8_t instance, flexcan_event_type_t eventType,
uint32_t buffIdx, flexcan_state_t *flexcanState) {
if (eventType == FLEXCAN_EVENT_RX_COMPLETE) {

CAN_A_RX_Complete();
return;
}

}

--------------------------------------------------------------------------

Thank you in advance for your time .

0 Kudos
Reply
2 Replies

864 Views
Krishnayya
Contributor I

Thank you for your support it's working now.

0 Kudos
Reply

882 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you should install single even callback and use it e.g. this way

FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1,CAN_TX_RX_Callback, NULL);

void CAN_TX_RX_Callback(uint8_t instance, flexcan_event_type_t eventType, uint32_t mb_num,
flexcan_state_t *flexcanState)
{
(void)flexcanState;
(void)instance;

switch(eventType)
{
case FLEXCAN_EVENT_RX_COMPLETE:
{
/* process data from recvBuff1 */

/* enable receiving data in RX_MAILBOX again */
// FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MB1, &recvBuff1);
}
break;
case FLEXCAN_EVENT_RXFIFO_COMPLETE:
{
/* process data from recvBuff2 */

/* enable receiving data in RX FIFO again */
// FLEXCAN_DRV_RxFifo(INST_CANCOM1,&recvBuff2);
}
break;
case FLEXCAN_EVENT_TX_COMPLETE:
break;
default:
break;
}
}

MB interrupt (and so calling of callback as well) is disabled once serviced, until you call Receive/Send functions again so MB interrupt is enabled and called upon successful message reception/transmission. 

BR, Petr

0 Kudos
Reply