FlexCAN issue in s32k144

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

FlexCAN issue in s32k144

1,272 Views
muhammadimranaf
Contributor II

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

lukaszadrapaPetrSTomE

Tags (2)
0 Kudos
2 Replies

798 Views
TomE
Specialist II

Your entire "fault report" seems to be:

> I am not able to run this flexcan module.

Sounds like you haven't done anything at all. If you have, you should SAY what you've done so that anybody responding doesn't waste time suggesting them.

There's a whole bunch of obvious things, like checking the pins for the correct state with an oscilloscope, trying an internal loopback, checking to see if the unit completed initialisation, saying if transmits complete or are stalled, checking all the error bits.

Tom

0 Kudos

798 Views
muhammadimranaf
Contributor II

I just wanted to have you guys check if pin initialization are ok.

I have already checked registers and error bits. On pin outs I don't see any communication on TxD or RxD. Now I doubt on the initialization of pins that are for CAN_RX and CAN_TX.

PORTE->PCR[4] = PORT_PCR_MUX(5); /*PORT_MUX_AS_CAN_RX*/  
PORTE->PCR[5] = PORT_PCR_MUX(5); /*PORT_MUX_AS_CAN_TX*/

Is there anything else that I have to set for these two pins. like pull-up or pull-down or something like that.

Regards,

Muhammad Imran Afzal

0 Kudos