2025-06-11 11:50 AM
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);
}
}
2025-06-11 12:55 PM
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.
2025-06-12 5:53 AM
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.
2025-06-12 6:13 AM
Check if the transceiver is not in the standby mode.
2025-06-12 6:21 AM
Looking through the reference manual, I don't see anything regarding Standby mode of the transceiver.
2025-06-12 6:47 AM
Is that the part of the hardware you are using?
2025-06-12 7:15 AM - edited 2025-06-12 7:17 AM
Yes, that is. I have tried connecting a scope to B1 and B0 to check for a signal before the transceiver. At start of program, all it does is jump to 5V and stay there. Do you know of any sample code that includes Normal mode CAN examples? I can only find Loopback CAN sample code.