AnsweredAssumed Answered

ticket

Question asked by MING-WEI GAO on May 5, 2019
Latest reply on May 9, 2019 by Petr Stancik

I have some problem about CAN_TX in MPC5746R.

there are my code and i can't get the right date in Oscilloscope.

I didn't know what's wrong. Can someone give me a hand?   thank you very much.

 

int main(void)

{
/* Write your local variable definition here */

#define TX_MAILBOX (1UL)
#define TX_MSG_ID1 (1UL)
#define TX_MSG_ID2 (2UL)
#define RX_MAILBOX (0UL)
#define RX_MSG_ID1 (2UL)
#define RX_MSG_ID2 (1UL)

uint8_t TX_date[1];
uint8_t TX_date1[1];


/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Write your code here */


CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
                            g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);

PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM2, &canCom2_State, &canCom2_InitConfig0);


flexcan_data_info_t dataInfo =
{
.data_length = 1UL,
.msg_id_type = FLEXCAN_MSG_ID_STD
};


/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &dataInfo, RX_MSG_ID1);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM2, RX_MAILBOX, &dataInfo, RX_MSG_ID2);

 


while(1)
{

 

/* Configure TX message buffer with index TX_MSG_ID1 and TX_MAILBOX*/
FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, TX_MAILBOX, &dataInfo, TX_MSG_ID1);
FLEXCAN_DRV_ConfigTxMb(INST_CANCOM2, TX_MAILBOX, &dataInfo, TX_MSG_ID2);

TX_date[0] = 0x11U;

/* Execute send non-blocking */
FLEXCAN_DRV_Send(INST_CANCOM1, TX_MAILBOX, &dataInfo, TX_MSG_ID1, (uint8_t*)TX_date);

// FLEXCAN_DRV_Send(INST_CANCOM2, TX_MAILBOX, &dataInfo, TX_MSG_ID2, &TX_date1);

// FLEXCAN_DRV_SendBlocking(INST_CANCOM1, TX_MAILBOX, &dataInfo, TX_MSG_ID2, &TX_date, 200);

}

 

Attachments

Outcomes