Having problem while transmitting can message using s32k312 evaluation board

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

Having problem while transmitting can message using s32k312 evaluation board

350 Views
Mohmedsohel
Contributor II

 

Hello NXP Community,

I am currently working with the S32K312EVB-Q172 board and trying to transmit and receive CAN messages. I have implemented two approaches: one using the PIT timer and the other with basic CAN. Both projects build successfully without any errors. However, I am facing an issue where I am unable to transmit or receive any CAN frames. There are no errors displayed during transmission, making it difficult to diagnose the problem.

Here is a brief summary of my setup:

  • Board: S32K312EVB-Q172
  • CAN configuration: Basic CAN and PIT-based CAN message transmission
  • System clock frequency: 120 MHz ,Peripheral frequency 24 MH

 

/*!
** Copyright 2019 NXP
** @file main.c
** @brief
**         Main module.
**         This module contains user's application code.
*/
/*!
**  @addtogroup main_module main module documentation
**  @{
*/
/* MODULE main */


/* Including necessary configuration files. */
#include "Mcal.h"
#include "Clock_Ip.h"
#include "FlexCAN_Ip.h"
#include "IntCtrl_Ip.h"

#define MSG_ID 0x123
#define RX_MB_IDX 1U
#define TX_MB_IDX 0U
volatile int exit_code = 0;
/* User includes */
uint8 dummyData[8] = {1,2,3,4,5,6,7};
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
extern void CAN0_ORED_0_31_MB_IRQHandler(void);

int main(void)
{
    /* Write your code here */
    Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);

    IntCtrl_Ip_EnableIrq(FlexCAN0_1_IRQn);
    IntCtrl_Ip_InstallHandler(FlexCAN0_1_IRQn, CAN0_ORED_0_31_MB_IRQHandler, NULL_PTR);

    Flexcan_Ip_DataInfoType rx_info = {
            .msg_id_type = FLEXCAN_MSG_ID_STD,
            .data_length = 8u,
            .is_polling = TRUE,
            .is_remote = FALSE
    };
    Flexcan_Ip_MsgBuffType rxData;
    FlexCAN_Ip_Init(INST_FLEXCAN_0, &FlexCAN_State0, &FlexCAN_Config0);
    FlexCAN_Ip_SetStartMode(INST_FLEXCAN_0);

    FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX, &rx_info, MSG_ID);
    rx_info.is_polling = FALSE;

    FlexCAN_Ip_Send(INST_FLEXCAN_0, TX_MB_IDX, &rx_info, MSG_ID, (uint8 *)&dummyData);

    FlexCAN_Ip_Receive(INST_FLEXCAN_0, RX_MB_IDX, &rxData, TRUE);

    while(FlexCAN_Ip_GetTransferStatus(INST_FLEXCAN_0, RX_MB_IDX) != FLEXCAN_STATUS_SUCCESS)
    { FlexCAN_Ip_MainFunctionRead(INST_FLEXCAN_0, RX_MB_IDX); }
    FlexCAN_Ip_SetStopMode(INST_FLEXCAN_0);
    FlexCAN_Ip_Deinit(INST_FLEXCAN_0);
    return 0;
}

/* END main */
/*!
** @}
*/

​

Z

 

  • No errors during build or transmission, but no frames are observed on the bus

I have verified the physical connections and basic CAN configuration but have been unable to identify the root cause of the issue. Could you please provide guidance or suggest potential areas to investigate further?

Any assistance would be greatly appreciated.

Tags (2)
0 Kudos
Reply
2 Replies

327 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

basic code looks correct, but it is not clear of module and pins setting. So be sure pins connected to CAN transceiver are configured. Have CAN transceiver active and properly terminated. Be sure FlexCAN module is set for Normal mode, demo examples uses loopback mode. Check CAN bit timing setting, if it is same as on opposite node connected. 
You can inspect MCR, ECR and ESR1 registers in debugger to know module status and if any errors are detected.

You can refer to some examples;
https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K312-CAN-Transmit-amp-Receive-Using-Poll...
https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K312-CAN-Transmit-amp-Receive-Using-MB-I...

BR, Petr

0 Kudos
Reply

315 Views
Mohmedsohel
Contributor II

Hello,

Thank you for your prompt response and guidance. I have carefully reviewed all the suggestions you provided and cross-checked the configurations. Everything seems to be in order based on your instructions.

I am attaching two files for further reference:

  1. The example code.
  2. The code using PIT for CAN message transmission, along with all relevant configurations.

Both projects are updated, but unfortunately, I am still unable to transmit CAN frames. The configurations, paths, and generated files appear correct, yet the issue persists.

I would appreciate it if you could review the attached files and provide further insights or suggestions on resolving this issue.

Thank you once again for your support. @PetrS  @nxp 

Tags (2)
0 Kudos
Reply