FlexCAN IP CAN status TJA1153 configuration not running

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

FlexCAN IP CAN status TJA1153 configuration not running

403 Views
erinc
Contributor III

Hi,

I am trying to activate TJA1153 Secure CAN with S32K344 non-autosar version using SDK 3.0.0.

I am testing on CANHUBK344 board and its 4th and 5th CANs are TJA1153.

CAN instance 4 set to normal mode. I am not using legacy mode.

FlexCAN4.png

 

The below code is used to setup for TJA1153 configuration. This return success! 

 

 

void setupCanTJA1153(int instance, Siul2_Dio_Ip_GpioType * const stb_port,
		Siul2_Dio_Ip_PinsChannelType stb_pin)
{
	Flexcan_Ip_DataInfoType tx_info = {
			.msg_id_type = FLEXCAN_MSG_ID_STD,
			.data_length = 8u,
			.fd_enable = FALSE,
			.fd_padding = FALSE,
			.enable_brs = FALSE,
			.is_polling = FALSE,
			.is_remote = FALSE
	};
	Flexcan_Ip_StatusType canst;
	
#define TJA1153_START_ID   (uint32_t)(0x555u)
#define TJA1153_CONFIG_ID  (uint32_t)(0x18DA00F1u)

	uint8 sendData[8]={0,0,0,0,0,0,0,0};


	/* Allow configuration from local host via TXD pin for CAN transceiver */
//	Siul2_Dio_Ip_WritePin(stb_port, stb_pin, 1U); //wake-up normal mode
	Siul2_Dio_Ip_WritePin(stb_port, stb_pin, 0U); //local-config mode

	/* Auto bit rate detection initial CAN Classic frame with ID 0x555 for CAN0 */
	tx_info.is_polling = TRUE;
	tx_info.msg_id_type = FLEXCAN_MSG_ID_STD;
	tx_info.data_length=0;
	canst = FlexCAN_Ip_SendBlocking(instance, TX_MB_IDX, &tx_info, TJA1153_START_ID, sendData, 100);

	sendData[0]= 0x10;
	sendData[1]= 0x00;
	sendData[2]= 0x50;
	sendData[3]= 0x00;
	sendData[4]= 0x07;
	sendData[5]= 0xFF;

	tx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
	tx_info.data_length = 6;
	canst = FlexCAN_Ip_SendBlocking(instance, TX_MB_IDX, &tx_info, TJA1153_CONFIG_ID, sendData, 100);
	//config command 10 part 0

	sendData[0]= 0x10;
	sendData[1]= 0x01;
	sendData[2]= 0x9f;
	sendData[3]= 0xff;
	sendData[4]= 0xff;
	sendData[5]= 0xff;

	tx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
	tx_info.data_length = 6;

	canst = FlexCAN_Ip_SendBlocking(instance, TX_MB_IDX, &tx_info, TJA1153_CONFIG_ID, sendData, 100);
	//config command 10 part 1

	sendData[0]= 0x10;
	sendData[1]= 0x02;
	sendData[2]= 0xc0;
	sendData[3]= 0x00;
	sendData[4]= 0x00;
	sendData[5]= 0x00;

	tx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
	tx_info.data_length = 6;

	canst = FlexCAN_Ip_SendBlocking(instance, TX_MB_IDX, &tx_info, TJA1153_CONFIG_ID, sendData, 100);
	//config command 10 part 2

	sendData[0]= 0x71;
	sendData[1]= 0x02;
	sendData[2]= 0x03;
	sendData[3]= 0x04;
	sendData[4]= 0x05;
	sendData[5]= 0x06;
	sendData[6]= 0x07;
	sendData[7]= 0x08;

	tx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
	tx_info.data_length=8;

	canst = FlexCAN_Ip_SendBlocking(instance, TX_MB_IDX, &tx_info, TJA1153_CONFIG_ID, sendData, 100);
	//config end leave open config

	/* After the last frame, the transceiver exits configuration mode and goes to standby mode, exit
	 * to normal operation mode is done by setting the STB pin of CAN transceiver to HIGH (pin is negated) */
	Siul2_Dio_Ip_WritePin(stb_port, stb_pin, 1U);
}

 

 

after that below one is written to test

 

 

#define RX_MB_IDX 1U
		
Flexcan_Ip_DataInfoType rx_info = {
				.msg_id_type = FLEXCAN_MSG_ID_EXT,
				.data_length = 8u,
				.fd_enable = false,
				.fd_padding = FALSE,
				.enable_brs = TRUE,
				.is_polling = FALSE,
				.is_remote = FALSE
		};
		Status_Init_FlexCAN = FlexCAN_Ip_ConfigRxMb(4u, RX_MB_IDX, &rx_info, 0x123);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
		{
			return NULL;
		}
		rx_info.msg_id_type = FLEXCAN_MSG_ID_STD;
		Status_Init_FlexCAN = FlexCAN_Ip_ConfigRxMb(4u, RX_MB_IDX+1, &rx_info, 0x18ff0001);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
		Status_Init_FlexCAN = FlexCAN_Ip_SetRxMaskType_Privileged(4u, FLEXCAN_RX_MASK_INDIVIDUAL);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
		Status_Init_FlexCAN = FlexCAN_Ip_SetRxMbGlobalMask_Privileged(4u, 0x3fffffff);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
		Status_Init_FlexCAN = FlexCAN_Ip_SetRxMb14Mask_Privileged(4u, 0x3fffffff);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
		Status_Init_FlexCAN = FlexCAN_Ip_SetRxMb15Mask_Privileged(4u, 0x3fffffff);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
		Status_Init_FlexCAN = FlexCAN_Ip_SetRxFifoGlobalMask_Privileged(4u, 0x0);
		if(Status_Init_FlexCAN != FLEXCAN_STATUS_SUCCESS)
			{
				return NULL;
			}
//	}
		FlexCAN_Ip_EnableInterrupts_Privileged(4u);
	FlexCAN_Ip_SetStartMode(4u);

 

 

nothing returns null, so this seems OK

But any receiving or transmitting attempt fails with following code. Also CAN Bus becomes heavy when I try to send any external message. Termination resistor is connected.

 

 

 

#define TX_MB_IDX 0U
#define RX_MB_IDX 1U
uint8 can_data[8] = {0};
Flexcan_Ip_DataInfoType can_msg_info= {
		.msg_id_type = FLEXCAN_MSG_ID_STD,
		.data_length = 8u,
		.is_polling = TRUE,
		.is_remote = FALSE
    };

CAN_st = FlexCAN_Ip_Send(4U, TX_MB_IDX, &can_msg_info, 0x123, (uint8 *)&can_data);
CAN_st = FlexCAN_Ip_Receive(4U, RX_MB_IDX, &rx_msg, TRUE);

 

 

 

Any callback/interrupt is not rising  even I define them. I am keeping STB_N and EN pins as High. I am suspecting that I am not able to hold CAN module in Normal mode and it goes other mode maybe (secure or configuration).

Is there a way to understand CAN module is active and in which state? 

or can you suggest any non-autosar example that use SDK?

 

Project is attached. Thanks in advance.

regards

 

Tags (3)
0 Kudos
4 Replies

384 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can read module MCR and ESR1 registers to know its status.
I tested attached code I created with this board, but it is using RTD203

BR, Petr

0 Kudos

362 Views
erinc
Contributor III

Hi,

I noticed that the interrupt starts working when I add some delaying feature like toggling a LED or printf (just for testing) in it.

 

void flexcan4_Callback(uint8 instance, Flexcan_Ip_EventType eventType, uint32 buffIdx, const Flexcan_Ip_StateType *flexcanState)
{
	(void)flexcanState;
	(void)instance;
//	printf("can4 callback: %d\n", eventType);
	Siul2_Dio_Ip_TogglePins(CAN4_LED_PORT, (1 << CAN4_LED_PIN));
	switch(eventType)
	{
	case FLEXCAN_EVENT_RX_COMPLETE:
		dummyData[0]++;
		if(buffIdx==1) // MB1 received
		{
			FlexCAN_Ip_Send(INST_FLEXCAN_4, TX_MB_IDX, &tx_info, rxData.msgId, (uint8 *)&dummyData);
//			FlexCAN_Ip_Receive(INST_FLEXCAN_4, 1, &rxData, false);
		}
		break;
	case FLEXCAN_EVENT_RXFIFO_COMPLETE:
		printf("RXFIFO Comp\n");
		break;
	case FLEXCAN_EVENT_TX_COMPLETE:
		if(buffIdx==0) // MB0 received
		{
			FlexCAN_Ip_Receive(INST_FLEXCAN_4, RX_MB_IDX, &rxData, false);
		}

		break;

 @PetrS thank you so far. What do you suggest? without delay in interrupt, does it re-calling before sending or receiving or else?

 

regards

0 Kudos

358 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I see in your code that you are using non-blocking Send/Receive functions with polling option enabled. That is Receive(...,true) and Send(..,&txinfo) with txinfo.is_polling=true. In that case callback will not be enterred unless FlexCAN_Ip_MainFunctionWrite/FlexCAN_Ip_MainFunctionRead is called periodically.

Do not use polling mode so interrupt/callback is normally called.

BR, Petr

0 Kudos

369 Views
erinc
Contributor III

Hi PetrS,
I tried your code in RTD300 (RTD203 gives error for missing files, etc.). Physical connection between CAN4 and CAN0 is established including termination resistor.
Results in MCR and ESR seems that Abort enabled (See below).

I am also suspecting no interrupt for CAN is calling which means.it is not receiving anything right?

I connect external CAN device (P-CAN) to listen bus but there is no message traffic.

Screenshot 2024-01-19 101426.png

Screenshot 2024-01-19 101720.png

0 Kudos