RXrdy read at 1 indicates
the presence of at least one frame in the reception file. Write in this
bit does not affet it.
TXrdy read at 1 indicates the presence of at least one frame in the
transmission file. Write in this bit does not affet it.
RXmsq at 1 hides the reception interrupt activated if RXrdy is at 1.
TXmsq at 1 hides the transmission interrupt activated if TXrdy is at 1.
RXclr erases the reception file when it is set to 1. It is already read
at 0.
TXclr erases the transmission file when it is set to 1. It is already
read at 0.
LPB loops back TX on RX when it is set to 1. In this case:
- the CAN device is not connected to the external bus,
- the filters discard the uncompliant frames.
AF1 to 4 allows, when there are set to 1, to take account the
corresponding acceptance filters. In initialization, these bits are se
to 0, all the frames are accepted.
The CAN_BRPR register contains the generator of time quantum:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
BRP15
|
BRP14
|
BRP13
|
BRP12
|
BRP11
|
BRP10
|
BRP9
|
BRP8
|
BRP7
|
BRP6
|
BRP5
|
BRP4
|
BRP3
|
BRP2
|
BRP1
|
BRP0
|
tq = (BRP+1)/25000000
The CAN_BTR register contains the sample configuration of each bit:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
réservé
|
réservé
|
réservé
|
réservé
|
réservé
|
SJW1
|
SJW0
|
PRS2
|
PRS1
|
PRS0
|
PHS12
|
PHS11
|
PHS10
|
PHS22
|
PHS21
|
PHS20
|
tbit = (1+PRS+PHS1+PHS2)*tq
The CAN_TEC contains the transmit error counter:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
TEC7
|
TEC6
|
TEC5
|
TEC4
|
TEC3
|
TEC2
|
TEC1
|
TEC0
|
The CAN_REC contains the receiver error counter:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
REC7
|
REC6
|
REC5
|
REC4
|
REC3
|
REC2
|
REC1
|
REC0
|
The acceptance filter registers have a 32 bits size distributed in 2 16
bits words:
CAN_AFMR
CAN_AFIR
|
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
H
|
ID28
|
ID27
|
ID26
|
ID25
|
ID24
|
ID23
|
ID22
|
ID21
|
ID20
|
ID19
|
ID18
|
SRR
RTR
|
IDE
|
ID17
|
ID16
|
ID15
|
L
|
ID14
|
ID13
|
ID12
|
ID11
|
ID10
|
ID9
|
ID8
|
ID7
|
ID6
|
ID5
|
ID4
|
ID3
|
ID2
|
ID1
|
ID0
|
RTR
|
CAN_AFMRx_H/L contains the mask of the bits to take account by the
filter x. A bit is take account when it is set to 1.
CAN_AFIRx_H/L contains the value of the bits to take account by the
filter x.
For
each configurated filter, the CAN controller compares the frame ID of
the received message hide by CAN_AFMRx_H/L with
CAN_AFIRx_H/L&CAN_AFMRx_H/L and accepts the frame when equal.
To configurate a filter, first set to 0 the AFx bit, write the wanted
values in the registers CAN_AFMRx_H/L e
CAN_AFIRx_H/L then set to 1 the AFx bit.
In order to filter the CAN frames, at least 1 of the 4 filters must be
configurated.
The frame received or to be transmitted is included in the registers
CAN_ID_H/L, CAN_DLC, CAN_DATA_01/23/45/67.
The CAN_ID_H/L register contains:
CAN_ID
|
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
H
|
ID28
|
ID27
|
ID26
|
ID25
|
ID24
|
ID23
|
ID22
|
ID21
|
ID20
|
ID19
|
ID18
|
SRR
RTR
|
IDE
|
ID17
|
ID16
|
ID15
|
L
|
ID14
|
ID13
|
ID12
|
ID11
|
ID10
|
ID9
|
ID8
|
ID7
|
ID6
|
ID5
|
ID4
|
ID3
|
ID2
|
ID1
|
ID0
|
RTR
|
The CAN_RF register, only used is reception mode, contains:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
AF3
|
AF2
|
AF1
|
AF0 |
In reading mode only (reception), the AF1 to 4 bits are
set to 1 when the received frame is accepted by the corresponding
filter.
The CAN_DLC register contains:
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
DLC3
|
DLC2
|
DLC1
|
DLC0 |
The CAN_DATA_xx registers contain the frame data:
CAN_DATA
|
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
D9
|
D8
|
D7
|
D6
|
D5
|
D4
|
D3
|
D2
|
D1
|
D0
|
01
|
D07
|
D06
|
D05
|
D04
|
D03
|
D02
|
D01
|
D00
|
D17
|
D16
|
D15
|
D14
|
D13
|
D12
|
D11
|
D10
|
23
|
D27
|
D26
|
D25
|
D24
|
D23
|
D22
|
D21
|
D20
|
D37
|
D36
|
D35
|
D34
|
D33
|
D32
|
D31
|
D30
|
45
|
D47
|
D46
|
D45
|
D44
|
D43
|
D42
|
D41
|
D40
|
D57
|
D56
|
D55
|
D54
|
D53
|
D52
|
D51
|
D50
|
67
|
D67
|
D66
|
D65
|
D64
|
D63
|
D62
|
D61
|
D60
|
D77
|
D76
|
D75
|
D74
|
D73
|
D72
|
D71
|
D70
|
In reading mode, a frame is present if the RXrdy bit is at 1.
The software must so read the registers CAN_ID_H to CAN_DATA_67 in
this order, whatever the frame length (DLC). Reading of CAN_DATA_67
pops the receive frame in the reception file. The reading must be done
again until the RXrdy bit becames 0 signaling that the reception file
is empty.
In writing mode, if the TXrdy bit is set to 1, the software can
write a new frame to transmit in the registers CAN_ID_H to
CAN_DATA_67
in this order, whatever the frame length (DLC). The writing of
CAN_DATA_67 pushes the transmit frame in the transmission file.
The writing can be done again while the TXrdy bit is set to 1 signaling
that the transmission file is not full.
During the initialization,
as a FORTH core RESET, CAN_CTRL is writen with the value 0x0C00 which
hides the interruptions and inhibates the acceptance filters.
The software must so configurate the eventual used filter contents if
necessary. CAN_CTRL can so be writen with the corresponding AFx bits,
erase the reception and transmission files and eventualy unmask the
interruptions if the CAN bus is managed also.