3 Example Code

The example code provided alongside this document was written for the PIC18F26K83. It is intended for use with the PIC18F26K83 PIM connected to the Automotive Networking Development Board, alongside a CAN transceiver click board (For example, the ATA6563 Click Board or MCP2542 Click Board).

The code implements a version of the algorithm and flowchart described in section 2.2. On first power-up, it begins with a baud rate of 500k, then cycles through 250k, 125k, and 100k baud rates, then upon finding the correct baud rate, stores this baud rate in EEPROM as the new starting baud rate, and illuminates the LED to indicate it has completed the auto-baud procedure. Afterwards, further messages sent over the bus with a message ID 0x123 (due to application mask/filter settings) will cause the LED to toggle.

As previously mentioned, auto-baud requires an existing CAN bus of two or more devices. This application note can be utilized with an existing CAN bus, but for demonstration/diagnostic purposes, it can often be easier to use such a tool as one from the K2L Optolyzer® MOCCA family (www.k2l.de/products/39/OptoLyzer%C2%AE%20MOCCA%20FD/). This and similar tools can simulate multiple nodes on a CAN bus and thus be used to demonstrate the autobaud functionality while only needing the K83 as an actual device on the bus.