Skip to main content
Associate II
June 11, 2025
Question

SPC560P-DISP CAN TX

  • June 11, 2025
  • 1 reply
  • 686 views

I've got the CAN Test app loaded and working as it should. I'm trying to get it to transmit out instead of loopback. I've already uncheck the option for loopback and simplified the code to only transmit. However, I don't see any activity on the CAN pins of the board. I've tried moving the jumpers from CAN0 to CAN1 and I've tried looking at the signal before the transceiver but still nothing. My code is attached below. Any help would be greatly appreciated!

#include "components.h"
#include "can_lld_cfg.h"

/**
 * FLEXCAN Error callback. This is kept for good practice but is not essential
 * for transmitting.
 */
void cfg0_errorcb(CANDriver *canp, uint32_t esr,uint8_t rx_err_counter, uint8_t tx_err_counter){
 (void)canp;
 (void)esr;
 (void)rx_err_counter;
 (void)tx_err_counter;
}

/**
 * FIFO notification callback. This is no longer used since we are only
 * transmitting messages.
 */
void cfg0_Fifo_RX(CANDriver *canp, CANRxFrame crfp) {
 (void)canp;
 (void)crfp;
}

/*
 * Application entry point.
 */
int main(void) {

 /* Define the CAN transmission frame */
 CANTxFrame txmsg;

 /* Initialize all the necessary components */
 componentsInit();

 /* Enable Interrupts for the CAN driver to function */
 irqIsrEnable();

 /*
 * Activate the CAN driver with the specified configuration.
 */
 can_lld_start(&CAND1, &can_config_cfg0);

 /*
 * Configure the CAN message that will be sent repeatedly.
 */
 txmsg.IDE = CAN_IDE_STD; // Use an extended 29-bit identifier
 txmsg.EID = 0x2F; // The extended identifier value
 txmsg.RTR = CAN_RTR_DATA; // This is a data frame, not a remote frame
 txmsg.LENGTH = 8U; // The message will have 8 bytes of data
 txmsg.data32[0] = 0x11223344U; // First 4 bytes of data
 txmsg.data32[1] = 0x55667788U; // Second 4 bytes of data

 /* Application main loop.*/
 for ( ; ; ) {

 /* Transmit the CAN message using mailbox 1.
 * The while loop ensures that we wait if the mailbox is busy.
 */
 while (can_lld_transmit(&CAND1, 1, &txmsg) == CAN_MSG_WAIT) {
 }

 /* Wait for 250 milliseconds before sending the next message */
 osalThreadDelayMilliseconds(250UL);
 }
}

1 reply

mƎALLEm
Technical Moderator
June 11, 2025

Hello,

I'm not Automotive components expert.

But since you've disabled the looback mode (I suppose you intend to use the transceiver, you need another CAN node connected to establish a complete CAN bus. CAN is not SPI or UART. The sender needs to receive an ACK dominent bit from the receiver to complete the acknowledgement mechanism.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
BXSAuthor
Associate II
June 12, 2025

Hi,

Thanks for your reply. I do intend on using the transceiver. I have a PEAK CAN device that sends ACK bits. I had that device hooked up to see if I would see any messages but no messages were picked up. The jumper for the 120 ohm termination resistor is connected. I also tried using an oscilloscope to check for any activity both before and after the transceiver with no luck. I'm wondering if there is something else beyond just disabling loopback mode that I need to change. 

mƎALLEm
Technical Moderator
June 12, 2025

Check if the transceiver is not in the standby mode.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."