
M0A21/M0A23 Series
May 06, 2022
Page
619
of 746
Rev 1.02
M0
A21
/M
0
A
2
3
SE
RIES
TEC
H
NICAL
RE
FEREN
C
E
M
ANUAL
The value 0x8000 indicates that an interrupt is pending because the CAN Core has updated (not
necessarily changed) the Status Register (Error Interrupt or Status Interrupt). This interrupt has the
highest priority. The application software can update (reset) the status bits RxOk (CAN_STATUS[4]),
TxOk (CAN_STATUS[3]) and LEC (CAN_STATUS[2:0]), but a write access of the software to the Status
Register can never generate or reset an interrupt.
All other values indicate that the source of the interrupt is one of the Message Objects. IntId points to
the pending message interrupt with the highest interrupt priority.
The application software controls whether a change of the Status Register may cause an interrupt (bits
EIE (CAN_CON[3]) and SIE (CAN_CON[2])) and whether the interrupt line becomes active when the
Interrupt Register is different from zero (bit IE in the CAN Control Register). The Interrupt Register will
be updated even when IE is reset.
The application software has two possibilities to follow the source of a message interrupt. First, it can
follow the IntId in the Interrupt Register and second it can poll the Interrupt Pending Register.
An interrupt service routine that is reading the message that is the source of the interrupt may read the
message and reset the Message Object’s IntPnd at the same time (bit ClrIntPnd
(CAN_IFn_CMASK[3])). When IntPnd is cleared, the Interrupt Register will point to the next Message
Object with a pending interrupt.
Configuring the Bit Timing
Even if minor errors in the configuration of the CAN bit timing do not result in immediate failure, the
performance of a CAN network can be reduced significantly.
In many cases, the CAN bit synchronization will amend a faulty configuration of the CAN bit timing to
such a degree that only occasionally an error frame is generated. However, in the case of arbitration,
when two or more CAN nodes simultaneously try to transmit a frame, a misplaced sample point may
cause one of the transmitters to become error passive.
The analysis of such sporadic errors requires a detailed knowledge of the CAN bit synchronization inside
a CAN node and interaction of the CAN nodes on the CAN bus.
Bit Time and Bit Rate
CAN supports bit rates in the range of lower than 1 Kbit/s up to 1000 Kbit/s. Each member of the CAN
network has its own clock generator, usually a quartz oscillator. The timing parameter of the bit time (i.e.
the reciprocal of the bit rate) can be configured individually for each CAN node, creating a common bit
rate even though the oscillator periods of the CAN nodes (fosc) may be different.
The frequencies of these oscillators are not absolutely stable, small variations are caused by changes
in temperature or voltage and by deteriorating components. As long as the variations remain inside a
specific oscillator tolerance range (df), the CAN nodes are able to compensate for the different bit rates
by re-synchronizing to the bit stream.
According to the CAN specification, the bit time is divided into four segments (see Figure 6.16-7). The
Synchronization Segment, the Propagation Time Segment, the Phase Buffer Segment 1 and the Phase
Buffer Segment 2. Each segment consists of a specific, programmable number of time quanta (Table
6.16-3). The length of the time quantum (tq), which is the basic time unit of the bit time, is defined by
the CAN controller’s APB clock fAPB and the BRP bit (CAN_BTIME[5:0]) : tq = BRP / fAPB.
The Synchronization Segment, Sync_Seg, is that part of the bit time where edges of the CAN bus level
are expected to occur. The distance between an edge that occurs outside of Sync_Seg, and the
Sync_Seg is called the phase error of that edge. The Propagation Time Segment, Prop_Seg, is intended
to compensate for the physical delay time within the CAN network. The Phase Buffer Segments
Phase_Seg1 and Phase_Seg2 surround the Sample Point. The (Re-)Synchronization Jump Width
(SJW) defines how far a re-synchronization may move the Sample Point inside the limits defined by the
Phase Buffer Segments to compensate for edge phase errors.