50.8.1 CAN Controller Initialization
After power-up reset, the CAN controller is disabled. The CAN controller clock must be activated by the Power Management Controller (PMC) and the CAN controller interrupt line must be enabled by the interrupt controller.
The CAN controller must be initialized with the CAN network parameters. CAN_BR defines the sampling point in the bit time period. CAN_BR must be set before the CAN controller is enabled.
The CAN controller is enabled by setting the CAN_MR.CANEN bit. At this stage, the internal CAN controller state machine is reset, error counters are reset to 0, and error flags are reset to 0.
Once the CAN controller is enabled, bus synchronization is done automatically by scanning eleven recessive bits. The CAN_SR.WAKEUP bit is automatically set to 1 when the CAN controller is synchronized (WAKEUP and SLEEP are stuck at 0 after a reset).
The CAN controller can start listening to the network in Autobaud mode. In this case, the error counters are locked and a mailbox may be configured in Receive mode. By scanning error flags, the CAN_BR values synchronized with the network. Once no error has been detected, the application disables the Autobaud mode, clearing the CAN_MR.ABM bit.