Hi everyone:
First of all, my purpose is implement the can function on s32k358, and I am trying to modify by Can_Example_S32K358 for now. This example is can internal loopback test, I want to use it to modify to Can sent message then use PCAN-VIEW to check can message if the can sent message successful.
I already create the port configuration for VCU_CAN, pin "PTB0" & "PTB1", and the following is my main function, I can't get message by PCAN-VIEW, do anyone have idea or experience on this, I really need some help for this, thanks.
int main(void)
{
uint8 u8TimeOut = 100U;
CanIf_bTxFlag = FALSE;
CanIf_bRxFlag = FALSE;
/* Initialize the Mcu driver */
#if (MCU_PRECOMPILE_SUPPORT == STD_ON)
Mcu_Init(NULL_PTR);
#elif (MCU_PRECOMPILE_SUPPORT == STD_OFF)
Mcu_Init(&Mcu_Config_VS_0);
#endif /* (MCU_PRECOMPILE_SUPPORT == STD_ON) */
/* Initialize the clock tree and apply PLL as system clock */
Mcu_InitClock(McuConf_McuModeSettingConf_McuModeSettingConf_0);
/* Initialize all pins using the Port driver */
Port_Init(NULL_PTR);
/* Initialize CanIf driver */
CanIf_Init(NULL_PTR);
#if (MCU_NO_PLL == STD_OFF)
while ( MCU_PLL_LOCKED != Mcu_GetPllStatus() )
{
/* Busy wait until the System PLL is locked */
}
Mcu_DistributePllClock();
#endif
Mcu_SetMode(McuModeSettingConf_0);
/* Initialize Platform driver */
Platform_Init(NULL_PTR);
static Can_PduType Can_PduInfo;
/* Can_CreatePduInfo(id, swPduHandle,length, sdu) */
Can_PduInfo = Can_CreatePduInfo(0U, 0U, 8U, Can_au8Sdu8bytes);
/* Initilize Can driver */
#if (CAN_43_FLEXCAN_PRECOMPILE_SUPPORT == STD_ON)
Can_43_FLEXCAN_Init(NULL_PTR);
#else
Can_43_FLEXCAN_Init(&Can_43_FLEXCAN_Config_VS_0);
#endif
Can_43_FLEXCAN_SetControllerMode(CanController_0, CAN_CS_STARTED);
while(count<20)
{
if((Can_43_FLEXCAN_Write(CanHardwareObject_1, &Can_PduInfo) == E_OK))
{
/* Wait until the message is successfully sent */
//while(!CanIf_bTxFlag)
while((!CanIf_bTxFlag) && (u8TimeOut != 0U))
{
Can_43_FLEXCAN_MainFunction_Write();
Can_DummyDelay(100U); /* Optional delay */
u8TimeOut--;
}
/* Reset the flag for the next transmission */
CanIf_bTxFlag = FALSE;
count++;
}
Can_DummyDelay(1000U);
}
Can_43_FLEXCAN_SetControllerMode(CanController_0, CAN_CS_STOPPED);
Can_43_FLEXCAN_DeInit();
Exit_Example((CanIf_bTxFlag && CanIf_bRxFlag) == TRUE);
return (0U);
}
Thanks
BR, BillWen