 Hello and welcome to this presentation of the flexible data rate controller area network interface. It covers the main features of this interface which is widely used to connect the microcontroller to a CAN network. The flexible data rate controller area network is a standard serial differential bus broadcast interface that enables the microcontroller to communicate with external devices connected to the same network bus. The FD-CAN interface is highly configurable, enabling nodes to easily connect using just two wires. Applications benefit from a multi-master concept with message priority, object-oriented communication, i.e. no-node addressing but content identification, real-time capability with low message transfer latency and system-wide message consistency, i.e. error detection and management mechanism. The STM32G4 microcontroller embeds three FD-CAN controllers. The CAN subsystem supports three FD-CAN controllers named FD-CAN 1, FD-CAN 2 and FD-CAN 3. These three controllers are independent except for the clock unit and RAM which are shared and have the same functionalities. These controllers support both the basic extended CAN protocol versions 2.0, A and B with a maximum bit rate of 1 Mbps as well as the CAN FD protocol version 1.0 with up to 64 data bytes and a data bit rate of up to 8 Mbps. The CAN core contains the protocol controller and receive transmit shift registers. It handles all ISO 11898-1 2015 protocol functions and supports both 11-bit and 29-bit identifiers. The TX handler controls the message transfer from the message RAM to the CAN core while the Rx handler controls the transfer of received messages from the CAN core to the external message RAM. Two clock domains are implemented, the APB bus interface and the CAN core kernel clock and their four synchronization blocks are required between these two domains. A shared 0.8 kb message RAM memory is available. This RAM is used to contain the filters, buffers and FIFOs. The CAN subsystem IO signals and pins are detailed in this table. Two clocks are provided to the FD-CAN unit. FD-CAN CK, the kernel clock used to obtain the bit rate, FD-CAN APB, which is the APB clock used to access memory mapped registers and message RAM. Two interrupt outputs enable the FD-CAN unit to report events to the Cortex-M4 processor. An external 16-bit timestamp input port can be used by the FD-CAN unit to timestamp the transmission or the reception of a message. This timestamp is provided by timer contained in the FD-CAN block. FD-CAN RX and FD-CAN TX have to be connected to the transceiver. At last, the APB slave interface is internally split into three parts, each of them having a dedicated chip select, configuration, control and RAM access. The FD-CAN controller conforms with a CAN protocol version 2.0 part A, B and ISO 11898-1 2015 and CAN FD protocol with maximum 64 data bytes supported. Maximum bit rate in FD mode is 8 megabits per second. Each controller also supports two independent maskable interrupts, each one having 24 fully configurable interrupt flags. The controllers have a powered-down mode. They support error logging, AutoSAR, J1939 and separate signaling on reception of high priority messages. Up to three received messages can be stored in each of the two RX-FIFOs. The acceptance filter selects the FIFO to use. Up to three messages to transmit can be stored as part of the message RAM configured either as a TX-FIFO or as three separate TX buffers. Each entry of the RX-FIFO and TX-FIFO or TX-FIFO supports the maximum message size 64 bytes of payload. The TX-Event FIFO stores TX timestamps together with the corresponding message ID. There are two variants in the FD-CAN protocol. Long-frame mode or LFM, where the data field of a CAN frame may be longer than 8 bytes, up to 64 bytes. Fast-frame mode or FFM, where control field, data field and CRC field of a CAN frame are transmitted with higher bit rate compared to the beginning and to the end of the frame. This high data rate is typically 8 Mbps. Fast-frame mode can be used in combination with long-frame mode. The bit timing logic monitors the serial bus line and performs sampling and adjustment of the sample point by synchronizing on the start bit edge and re-synchronizing on the following edges. The time quantum is the basic timing unit obtained from the configuration unit and equal to TFD-CAN TQCK multiplied by a ratio from 1 to 512 programmed in the FD-CAN NBTP register. The bit time is split into three segments, the synchronization segment, the bit segment 1 and the bit segment 2. Each of these segments is an integer multiple of the time quantum. The duration of BS1 and BS2 is independently programmable for nominal bit time and data bit time. The data bit time applies when operating in FD mode and data is transmitted at the high data rate. In order to adjust the on-chip bus clock, the CAN controller may shorten or prolong the length of a bit by an internal number of quanta. The maximum value of these bit time adjustments are termed the synchronization jump width or SJW which is programmable from 1 to 4 time quanta. The transmitter delay compensation enables configurations where the data bit time is shorter than the transmitter delay. It's enabled by setting bit TDC in DBTP register. The received bit is compared against the transmitted bit at the secondary sample point. The SSP position is defined as the sum of the measured delay from the FD-CAN transmit output pin FD-CAN TX through the transceiver to the receive input pin FD-CAN RX plus the transmitter delay compensation offset. The transmitter delay compensation offset is used to adjust the position of the SSP inside the received bit, e.g. half of the bit time in the data phase. The FD-CAN has three main operating modes, initialization, normal and sleep. After a hardware reset, the FD-CAN enters initialization mode via software. In this mode, the peripheral must be configured for bit timings and RAM location. In the bit timing configuration, the rate is set when the sampling point is adjusted according to the actual serial bus line. The CAN controller then synchronizes itself with a CAN bus by waiting for 11 consecutive recessive bits. When the CAN is in normal mode, the user can select different specific sub modes. Classic CAN mode compatible with CAN specification 2.0B. FD-CAN mode, it can be long frame and or fast frame mode named respectively LFM and FFM. Restricted mode, the controller is able to receive data frames and acknowledge them, but does not send frames. It can be used in applications that adapt themselves to different CAN bit rates. Bus monitoring mode, the controller is able to receive data frames but cannot acknowledge them. It can be used to analyze the traffic on a CAN bus without affecting it by the transmission of dominant bits. Test modes detailed in next slide. Upon a CPU request, the FD-CAN is put in sleep mode, which operates at a lower power when bus idle state is detected. To enable write access to FD-CAN test register, bit test in CCCR register must be set to 1, thus enabling the configuration of test modes and functions. In test mode, software can control the state of the FD-CAN TX pin and can read the state of FD-CAN RX. Through the FD-CAN test register, software can control the FD-CAN TX output. Force dominant level, force recessive level, monitor the sample point. The actual value at pin FD-CAN RX can be read from RX bit in the FD-CAN test register. Both functions can be used to check the CAN bus physical layer. These test modes should be used for production tests or self-test only. Furthermore, the FD-CAN controller supports two loopback modes that are entered through control bits in the FD-CAN test and FD-CAN CCCR registers. In external loopback mode, the FD-CAN treats its own transmitted messages as received messages and stores them if they pass acceptance filtering into RX5Os. This mode is provided for hardware self-tests. To be independent from external stimulation, the FD-CAN ignores a knowledge errors in loopback mode. Internal loopback mode can be used for a hot self-test, meaning the FD-CAN can be tested without affecting a running CAN system connected to the FD-CAN TX and FD-CAN RX pins. In this mode, FD-CAN RX pin is disconnected from the FD-CAN and FD-CAN TX pin is held recessive. The FD-CAN controller offers the possibility to configure two sets of acceptance filters, one for standard 11-bit identifiers and another for 29-bit extended identifiers. Each filter element is configurable for acceptance or rejection filtering. Each filter element can be enabled or disabled individually. Filters are checked sequentially. Execution stops with the first matching filter element. Software configures the number of active filter instances, maximums 28. Acceptance filtering is started after the complete identifier has been received. After acceptance filtering has completed and if a matching RX5O has been found, the message handler starts writing the received message data in 32-bit portions to the matching RX5O. Each filter element can be configured as range filter from 2, filter for 1 or 2 dedicated IDs, classic bit mask filter. Regarding extended ID, the extended ID and mask, or XIDAM, is ended with the received identifier before the filter list is executed. To filter for one specific message ID, the filter element has to be configured with SF1ID equals SF2ID and EF1ID equals EF2ID. This algorithm describes the filtering sequence of frames received with a standard ID. A similar algorithm is used to handle frames received with an extended ID, however the configuration of these two algorithms is done independently. First step is accepting or rejecting the remote frames. Then, when the receiver list is disabled, the filter elements are bypassed. Otherwise, the first matching element determines whether the frame is accepted or rejected. When the receiver filter is disabled or no filtering elements has matched, the frame is either accepted or rejected. At last, when the frame is accepted and the targeted RX5O is not full, this frame is appended to the RX5O. When the RX5O is full and blocking mode is selected, then the frame is discarded. RX5O0 and RX5O1 can hold up to three elements each. Received messages that past acceptance filtering are transferred to the RX5O as configured by the matching filter element. The read-only registers fdcanrxf0s and fdcanrxf1s provide the following information. Position of the put index, position of the get index, number of pending messages, fifo full condition. The RX5O blocking mode is the default operation mode for the RX5Os. When an RX5O full condition is reached, no further messages are written to the corresponding RX5O until at least one message has been read out and the RX5O get index has been incremented. In case a message is received while the corresponding RX5O is full, this message is discarded and the message loss condition is signalled. In RX5O overwrite mode, when an RX5O full condition is signalled, the oldest message is discarded and the next message is accepted as shown in the sequence on the right. Put and get index are both incremented by one. Up to three TX buffers can be set up for message transmission. Either the TX5O mode is chosen in which all messages are transmitted in the same order that have been prepared by software or the TXQ mode is chosen in which the three message buffers are handled independently of each other. Messages stored in the TXQ are transmitted starting with a message with the highest priority. The FD-CAN controller supports transmit cancellation. To cancel a requested transmission from a TXQ buffer, software has to write a 1 to the corresponding bit position of registered TXBCR. Transmit cancellation is not intended for TXFIFO operation. To support TXEvent handling, the FD-CAN has implemented a TXEvent FIFO, the purpose of the TXEvent FIFO is to decouple handling transmit status information from transmit message handling. A TXBuffer holds only the message to be transmitted while the transmit status is stored separately in the TXEvent FIFO. This has the advantage, especially when operating a dynamically managed transmit queue, that a TXBuffer can be used for a new message immediately after successful transmission. There is no need to save transmit status information from a TXBuffer before overwriting that TXBuffer. In case a TXEvent occurs while the TXEvent FIFO is full, this event is discarded and interrupt flag is set. An FD-CAN controller peripheral provides two independent interrupt lines. This slide shows the complete list of possible interrupt events. Here is an overview of the FD-CAN subsystem low power configuration modes. The device is not able to perform any communications in stop or standby modes. It's important to ensure that all CAN traffic is completed before the peripheral enters stop or standby modes. While the CPU core is in debug mode, i.e. stopped at a breakpoint, then FD-CAN remains in its normal functioning mode. In particular, reception continues as normal and this may lead to reception overrun errors when FIFOs or buffers are full. Registers of the type reset on read or set on read are disabled. Reading them doesn't affect their value. For additional information, refer to the training for these peripherals which may affect FD-CAN behavior. Reset and clock controller or RCC for more information about the CAN clock control and enable or reset. Interrupts for more information about the mapping of the FD-CAN's interrupts. General purpose IOs or GPIO for more information about the FD-CAN's input and output pins. Debug support or DBG for more information about the FD-CAN's behavior in debug mode. Application notes covering the CAN topic are available on www.st.com. To learn more about the CAN interface, you can also visit a wide range of web pages discussing the CAN communication protocol and bus monitoring tools. Many digital oscilloscopes support direct reading and analysis of data transmitted over the CAN bus.