Hi NXP team,
I am working with the RDBESSK358BMU board and trying to bring up CAN using FlexCAN4 with the onboard CAN-FD transceiver.
At the end of post you can see my code.
I also selected the pins in S32 Design Studio based on my understanding of the board documentation and schematic, but it still does not work.
My current understanding is:
PTC30 → CAN4_TX
PTC31 → CAN4_RX
PTA7 → CAN_STB
PTD8 → CAN-FD_EN
PTD9 → CAN-FD_ERR
In S32DS pin configuration, I selected them as follows according to my interpretation:
PTC30 / CAN4_TX
PTC31 / CAN4_RX
PTD8 as GPIO Output
PTA7 as GPIO Output
PTD9 as GPIO Input
However, the setup is still not working.
I want to use normal mode only with the real external transceiver and real CAN bus.
I do not want loopback mode.
Also, when I try to run in normal mode, the board seems to reset.
1- Do you have a complete working example for:
RDBESSK358BMU
FlexCAN4
normal mode
external CAN transceiver enabled
correct pin settings
correct S32DS configuration
2- If possible, could you please provide:
a full working example project
or a minimal but complete initialization example
including:
clock init
pin mux
CAN transceiver control pins
FlexCAN4 init
start mode
transmit example in normal mode
My current code is as bellow also, the pin setting in S32DS is attached.
Thank you.
Saman
****************************************************************
#include "Mcal.h"
#include "OsIf.h"
#include "FlexCAN_Ip.h"
#include "FlexCAN_Ip_Cfg.h"
#include "Clock_Ip.h"
#include "Clock_Ip_Cfg.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Port_Ip_Cfg.h"
volatile int exit_code = 0;
int main(void)
{
Flexcan_Ip_DataInfoType txInfo;
uint8 txData[8] = {1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U};
/* Clock init */
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
/* Pin init */
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
/* OSIF init */
OsIf_Init(NULL_PTR);
/* CAN4 init */
FlexCAN_Ip_Init(4U, &FlexCAN_State0, &FlexCAN_Config0);
/* Start CAN controller */
FlexCAN_Ip_SetStartMode(4U);
/* CAN frame info */
txInfo.msg_id_type = FLEXCAN_MSG_ID_STD;
txInfo.data_length = 8U;
txInfo.fd_enable = FALSE;
txInfo.fd_padding = 0U;
txInfo.enable_brs = FALSE;
txInfo.is_polling = TRUE;
txInfo.is_remote = FALSE;
for (;;)
{
(void)FlexCAN_Ip_SendBlocking(4U, 0U, &txInfo, 0x123U, txData, 1000U);
for (volatile uint32 i = 0U; i < 1000000U; i++)
{
}
}
return exit_code;
}
Hello @samansaki,
You can select the "Switch package" option inside the Pins tool, and select the 172HDQFP package:
Best regards,
Julián
Hi Julián,
I currently have a problem in the debug stage of my code. The reset issue I mentioned is related to switching to normal mode, which I will ask about later as a separate issue. For now, I would like to solve the debug problem first.
I want to debug my code step by step, set breakpoints, and check the registers.
Specifically, I want to verify registers such as:
SIUL2 GPDO / GPDI
MSCR / IMCR configuration
FlexCAN registers
From the BMU board documentation (S32K358, 172-MQFP), I expect:
PTD8 -> pin 64 -> CAN_EN
PTD9 -> pin 63 -> CAN_ERR
PTA7 -> pin 100 -> CAN_STB
PTC30 -> pin 101 -> CAN4_TX
PTC31 -> pin 103 -> CAN4_RX
However, I noticed that when I select the S32K358 family in S32DS, the tool automatically assigns a default part number (S32K358 in 289-BGA), while my board uses the 172-MQFP package.
Because of this, the pin mapping is different, and I cannot reliably check the registers during debugging.
I searched in S32DS but could not find where to manually change the part number/package.
I have attached a screenshot showing this issue.
Best regards,
Saman
Hi @samansaki,
Your general configuration seems to be correct. How are you testing the CAN communication? Are you using something like the PCAN USB analyzer?
You can look through our community for some existing examples regarding RDBESSK358BMU or S32K358 in general, for example:
Now, regarding this sentence: "Also, when I try to run in normal mode, the board seems to reset." Could you clarify what this means? At which point in the application does the board reset?
Best regards,
Julián
Hi @samansaki,
Could you share how are you testing CAN communication? Are you using a PCAN USB analyzer? Are you able to scope the bus?
Unfortunately, I do not have the board with me right now, but I can share some S32K3X8 EVB CAN example if needed. Just help me sharing S32DS + RTD versions.
Anyway, RDBESSK358BMU board uses the TJA1463ATK CAN interface, which is operated by two control pins, STB_N and EN. For NORMAL mode, set HIGH levels on both STB_N and EN.
You can do this by writing 1 to the pin:
Siul2_Dio_Ip_WritePin(STB_N_PORT, STB_N_PIN, 1U);
Siul2_Dio_Ip_WritePin(EN_PORT, EN_PIN, 1U);
Other than that, basic configuration looks OK.
You could also check that the bit timing matches both nodes on the bus (Whatever you are using to test, eg. another board, PCAN USB, etc.)
Best regards,
Julián
Hi Julian
Thank you for your nice answer.
Regarding my main problem, I checked the examples you provided, and now I’m trying to send a very simple CAN message using FlexCAN on S32K358, but I’m stuck and not sure where the issue is.
I have been debugging this for quite some time, but I still cannot figure out what’s wrong.
My goal is simply to periodically send a basic CAN frame (8 bytes) using one TX message buffer.
Please take a look at my code below, as well as the attached screenshots from S32DS (registers, pin configuration, etc.):
#include "Mcal.h"
#include "Clock_Ip.h"
#include "Siul2_Port_Ip_Cfg.h"
#include "Siul2_Port_Ip.h"
#include "FlexCAN_Ip.h"
#define TX_MB_IDX 0U
#define MSG_ID 0x123U
uint8 txData[8] = {1,2,3,4,5,6,7,8};
uint32 canStatus;
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 = TRUE,
.is_remote = FALSE
};
int main(void)
{
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
FlexCAN_Ip_Init(INST_FLEXCAN_4, &FlexCAN_State0, &FlexCAN_Config0);
FlexCAN_Ip_SetStartMode(INST_FLEXCAN_4);
while (1)
{
canStatus = (uint32)FlexCAN_Ip_Send(INST_FLEXCAN_4, TX_MB_IDX, &tx_info, MSG_ID, txData);
txData[0]++;
for (volatile uint32 i = 0; i < 1000000U; i++)
{
}
}
}