I am implementing a CAN driver for the LPC1768 microcontroller. During testing , I am encountering an ERRBIT : start of frame (SOF) in CAN interrupt and capture status register(CANxICR) and I have not connected the receiver to the board i.e there is no receiving node on CAN bus.
My setup:
Software: keil u4
Microcontroller: LPC1768( ARM Cortex M3)
Baud rate: 500kbps
pin configuration: TD1(P0.1), RD1(P0.0)
CANxBTR register value: 0x00070004;
transmitter snippet:
void CAN_Transmit(uint8 CAN_Controller, CAN_msg *msg) {
if(CAN_Controller==1){
while (!(CAN1->SR & (1 << 2))); // Wait until TX buffer is empty
CAN1->TFI1 = ((msg->len &0xf)<< 16); // Set data length
CAN1->TID1 = msg->id; // Set identifier
CAN1->TDA1 = (msg->data[0]) | (msg->data[1] <<
CAN1->TDB1 = (msg->data[4]) | (msg->data[5] <<
CAN1->CMR = (1 << 5) | (1 << 0); // Request transmission
while(!(CAN1->GSR& (0x01<<3)));
}
else if(CAN_Controller==2){
while (!(CAN2->SR & (1 << 2))); // Wait until TX buffer is empty
CAN2->TFI1 = ((msg->len&0xf) << 16); // Set data length
CAN2->TID1 = msg->id; // Set identifier
CAN2->TDA1 = (msg->data[0]) | (msg->data[1] <<
CAN2->TDB1 = (msg->data[4]) | (msg->data[5] <<
CAN2->CMR = (1 << 5) | (1 << 0); // Request transmission
while(!(CAN2->GSR& (0x01<<3)));
}
}
I have verified my pin configuration and CAN settings but cannot identify why the error is persisting.
Request:
Could anyone suggest what might be causing the ERRBIT: Start of Frame and how to resolve it? Is it related to incorrect baud rate settings, pin configurations, or hardware connections?
Hello @Nisarga
Please connect the CAN receiver. CAN transmission requires an acknowledgment from the receiver, so it is necessary to connect a receiver. For the code implementation, you can refer to the CAN demo provided under LPCOpen.
BR
Alice