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:
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;
}