How can I implement a recovery mechanism for CAN Bus errors on the AVR128DA48 to avoid manual resets

I’m encountering error frames on the CAN Bus when two nodes try to send data simultaneously. I’m using the AVR128DA48 microcontroller. Below is my CAN Bus error handling code:
void can_error_handler(const struct zcan_frame *frame, void *arg) {
if (frame->error_flags) {
printk("CAN error: 0x%02x\n", frame->error_flags);
}
}
void can_error_handler(const struct zcan_frame *frame, void *arg) {
if (frame->error_flags) {
printk("CAN error: 0x%02x\n", frame->error_flags);
}
}
The system occasionally enters Bus Off mode, and I need to manually reset the CAN controller. How can I implement a proper recovery mechanism to handle CAN errors and automatically recover from Bus Off mode without manual intervention?
Solution:
hey guys, I fixed the issue with the system entering Bus Off mode by enabling automatic recovery on the AVR128DA48 microcontroller. Now, the controller automatically recovers after detecting 128 consecutive error-free frames. To make sure it works smoothly, I also added a backup that manually resets the CAN controller if the automatic recovery doesn’t kick in. Here’s the updated error handling code:...
Jump to solution
1 Reply
Solution
Dtynin
Dtynin3mo ago
hey guys, I fixed the issue with the system entering Bus Off mode by enabling automatic recovery on the AVR128DA48 microcontroller. Now, the controller automatically recovers after detecting 128 consecutive error-free frames. To make sure it works smoothly, I also added a backup that manually resets the CAN controller if the automatic recovery doesn’t kick in. Here’s the updated error handling code:
Want results from more Discord servers?
Add your server