Hello Community Members !
I'm presently working on CAN module in S32K144 EVB and looking for some support to send a dummy message through CAN0 module and sending it via PTE4 and PTE5 pins. And i'm using a CANanalyser to check for CAN messages. But I cant able to read it in Vector CAN box.
Do I've to change the clock configuration in CLOCK_SYS_Init or anything I've to change. My code has been attached for the reference. Please do let me know about any modification in it?
My Code:
#include "sdk_project_config.h"
#include <interrupt_manager.h>
#include <stdint.h>
#include <stdbool.h>
#include "peripherals_can_pal0.h"
#define MASTER
/*#define SLAVE*/
/* Definition of the TX and RX message buffers depending on the bus role */
#if defined(MASTER)
#define TX_MAILBOX (1UL)
#define TX_MSG_ID (1UL)
#define RX_MAILBOX (0UL)
#define RX_MSG_ID (2UL)
void BoardInit(void);
void BoardInit(void)
{
/* Initialize and configure clocks
* - Setup system clocks, dividers
* - Configure FlexCAN clock, GPIO
* - see clock manager component for more details
*/
//CLOCK_DRV_Init(&clockMan1_InitConfig0);
//Clock configuration
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
/* Initialize pins
* - Init FlexCAN and GPIO pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
}
volatile int exit_code = 0;
int main(void)
{
/* Do the initializations required for this application */
BoardInit();
CAN_Init(&can_instance0, &can_config0);
can_buff_config_t buff_config0 = {
.enableFD = false,
.enableBRS = false,
.fdPadding = 0,
.idType = CAN_MSG_ID_STD,
.isRemote = false
};
CAN_ConfigTxBuff(&can_instance0, TX_MAILBOX, &buff_config0);
// Example dummy message
can_message_t dummyMessage;
dummyMessage.id = 0x123; // Example message ID
dummyMessage.length = 8; // Example data length
dummyMessage.data[0] = 0xAA; // Example data bytes
// Populate other data bytes as needed
// Call CAN_Send function to send the message
status_t sendStatus =
CAN_Send(&can_instance0, TX_MAILBOX, &dummyMessage);
if (sendStatus != STATUS_SUCCESS) {
//Handle send error
}
CAN_Deinit(&can_instance0);
while(1) {
CAN_Init(&can_instance0, &can_config0);
CAN_Send(&can_instance0, TX_MAILBOX, &dummyMessage);
}
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
}