Hi,
I am trying to configure and run flexcan in s32k144. I am building a bare metal application and not in SDK. I am not able to run this flexcan module. Here are some things that I am using.
Board is an ECU with TJA1043 chip as transceiver for CAN with this configurations.
PTD5 -> CAN_ERR, PTD6 -> CAN_EN, PTD7 -> CAN_STBY, PTC17 -> CAN_INH, PTE4 -> CAN_RX, PTE5 -> CAN_TX
CAN transceiver initialization:
PORTD->PCR[5] = PORT_PCR_MUX(1); PORTD->PCR[6] = PORT_PCR_MUX(1);PORTD->PCR[7] = PORT_PCR_MUX(1);PORTD->PCR[17] = PORT_PCR_MUX(1);PORTD->PCR[6] = PORT_PCR_DSE(1); PORTD->PCR[7] = PORT_PCR_DSE(1);PTD->PDDR =GPIO_PDDR_PDD(0x20020); PTD->PSOR = GPIO_PSOR_PTSO(0x40); PORTE->PCR[4] = PORT_PCR_MUX(4); PORTE->PCR[5] = PORT_PCR_MUX(5);PTE->PDDR =GPIO_PDDR_PDD(0x20); PORTE->PCR[5] = PORT_PCR_DSE(1);
And I have enabled CAN clock.
/*init CAN clock*/
PCC->PCCn[PCC_FlexCAN0_INDEX] = PCC_PCCn_CGC(1);
/*initialize PORTs clock*/
PCC->PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC(1);
PCC->PCCn[PCC_PORTE_INDEX] = PCC_PCCn_CGC(1);
CAN parameters used:
#define DEF_ECU_ADDR ((uint8)0x41)
#define DEFAULT_CAN_SPEED ((uint16)500)
#define DEFAULT_CAN_NSJW ((uint8)2)
#define DEFAULT_CAN_TSEG1 ((uint8)4)
#define DEFAULT_CAN_TSEG2 ((uint8)2)
CAN driver is tested and it is working for MPC5748G board. Do you think there is any change in this flexcan and the one used in s32k144. I couldn't see any difference except s32k144 has FD support.
Can you check this thing and see if there is anything I am missing in these initialization.
Regards,
Muhammad Imran Afzal
lukaszadrapa PetrS TomE