AnsweredAssumed Answered

FlexCAN issue in s32k144

Question asked by muhammadimranafzal on Jul 13, 2017
Latest reply on Jul 14, 2017 by muhammadimranafzal

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); /*PORT_MUX_AS_GPIO*/    PORTD->PCR[6] = PORT_PCR_MUX(1);PORTD->PCR[7] = PORT_PCR_MUX(1);PORTD->PCR[17] = PORT_PCR_MUX(1);/*Configures the drive strength if the pin is used as a digital output*/PORTD->PCR[6] = PORT_PCR_DSE(1); /*PORT_HIGH_DRIVE_STRENGTH: high drive strength is configured.*/PORTD->PCR[7] = PORT_PCR_DSE(1);PTD->PDDR =GPIO_PDDR_PDD(0x20020); /* pin 5-> input, pin 6-> output, pin 7-> output, pin 17-> input*//*Port Set Output Register*/PTD->PSOR = GPIO_PSOR_PTSO(0x40);   /*pin 6 -> high, pin 7 -> low*/PORTE->PCR[4] = PORT_PCR_MUX(4);  PORTE->PCR[5] = PORT_PCR_MUX(5);PTE->PDDR =GPIO_PDDR_PDD(0x20); /* pin 4-> input, pin 5-> output*/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

Lukas Zadrapa Petr Stancik Tom Evans

Outcomes