Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
162
Добавлен:
01.03.2016
Размер:
3.56 Mб
Скачать

Controller area network (beCAN)

RM0016

 

 

If the application does not release the mailbox, the next valid message will be stored in the FIFO which enters pending_2 state (FMP[1:0] = 0b10). The storage process is repeated for the next valid message putting the FIFO into pending_3 state (FMP[1:0] = 0b11). At this point, the software must release the output mailbox by setting the RFOM bit, so that a mailbox is free to store the next valid message. Otherwise the next valid message received will cause a loss of message.

Refer also to Section 23.6.4: Message storage.

Overrun

Once the FIFO is in pending_3 state (i.e. the three mailboxes are full) the next valid message reception will lead to an overrun and a message will be lost. The hardware signals the overrun condition by setting the FOVR bit in the CAN_RFR register. Which message is lost depends on the configuration of the FIFO:

If the FIFO lock function is disabled (RFLM bit in the CAN_MCR register cleared) the last message stored in the FIFO will be overwritten by the new incoming message. As a result, the last message is always available to the application.

Note:

The previously received messages will stay in their positions in the FIFO, only the last one

 

will be overwritten.

If the FIFO lock function is enabled (RFLM bit in the CAN_MCR register set) the most recent message will be discarded and the software will have the three oldest messages in the FIFO available.

Reception related interrupts

On the storage of the first message in the FIFO - FMP[1:0] bits change from 0b00 to 0b01 - an interrupt is generated if the FMPIE bit in the CAN_IER register is set.

When the FIFO becomes full (i.e. a third message is stored) the FULL bit in the CAN_RFR register is set and an interrupt is generated if the FFIE bit in the CAN_IER register is set.

On overrun condition, the FOVR bit is set and an interrupt is generated if the FOVIE bit in the CAN_IER register is set.

23.6.3Identifier filtering

In the CAN protocol the identifier of a message is not associated with the address of a node but related to the content of the message. Consequently a transmitter broadcasts its message to all receivers. On message reception a receiver node decides - depending on the identifier value - whether the software needs the message or not. If the message is needed, it is copied into the RAM. If not, the message must be discarded without intervention by the software.

To fulfil this requirement, the beCAN Controller provides 6 configurable and scalable filter banks (5:0) in order to receive only the messages the software needs. This hardware filtering saves CPU resources which would be otherwise needed to perform filtering by software. Each filter bank x consists of eight 8-bit registers, CAN_FxR[8:1].

374/454

Doc ID 14587 Rev 9

RM0016

Controller area network (beCAN)

 

 

Scalable width

To optimize and adapt the filters to the application needs, each filter bank can be scaled independently. Depending on the filter scale a filter bank provides:

One 32-bit filter for the STDID[10:0] / EXID[28:18], IDE, EXID[17:0] and RTR bits.

Two 16-bit filters for the STDID[10:0] / EXID[28:18], RTR and IDE bits.

Four 8-bit filters for the STDID[10:3] / EXID[28:21] bits. The other bits are considered as don’t care.

One 16-bit filter and two 8-bit filters for filtering the same set of bits as the 16 and 8-bit filters described above.

Refer to Figure 148 through Figure 151.

Furthermore, the filters can be configured in mask mode or in identifier list mode.

Mask mode

In mask mode the identifier registers are associated with mask registers specifying which bits of the identifier are handled as “must match” or as “don’t care”.

Identifier list mode

In identifier list mode, the mask registers are used as identifier registers. Thus instead of defining an identifier and a mask, two identifiers are specified, doubling the number of single identifiers. All bits of the incoming identifier must match the bits specified in the filter registers.

Filter bank scale and mode configuration

The filter banks are configured by means of the corresponding CAN_FCRx register. To configure a filter bank this must be deactivated by clearing the FACT bit in the CAN_FCRx register. The filter scale is configured by means of the FSC[1:0] bits in the corresponding CAN_FCRx register. The identifier list or identifier mask mode for the corresponding Mask/Identifier registers is configured by means of the FMLx and FMHx bits in the CAN_FMRx register. The FMLx bit defines the mode for the lower half (registers CAN_FxR1-4), and the FMHx bit the mode for the upper half (registers CAN_FxR5-8) of filter bank x. Refer to Figure 148 through Figure 151 for details.

Examples:

If filter bank 1 is configured as two 16-bit filters, then the FML1 bit defines the mode of the CAN_F1R3 and CAN_F1R4 registers and the FMH1 bit defines the mode of the CAN_F1R7 and CAN_F1R8 registers.

If filter bank 1 is configured as four 8-bit filters, then the FML1 bit defines the mode of the CAN_F1R2 and CAN_F1R4 registers and the FMH1 bit defines the mode of the CAN_F1R6 and CAN_F1R8 registers.

Doc ID 14587 Rev 9

375/454

Controller area network (beCAN)

RM0016

 

 

Note:

In 32-bit configuration, the FMLx and FMHx bits must have the same value to ensure that

 

the four Mask/Identifier registers are in the same mode.

 

When a standard identifier is received (IDE bit is zero), the extended part of 32-bit or 16-bit filters is not compared.

To filter a group of identifiers, configure the Mask/Identifier registers in mask mode.

To select single identifiers, configure the Mask/Identifier registers in identifier list mode. Filters not used by the application should be left deactivated.

Each filter within a filter bank is numbered (called the Filter Number) from 0 to a maximum dependent on the mode and the scale of each of the 6 filter banks.

For the filter configuration, refer to Figure 148 through Figure 151.

Figure 148. 32-bit filter bank configuration (FSCx bits = 0b11 in CAN_FCRx register)

 

 

 

Filter registers

 

 

 

 

 

Filter mode1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mapping

STID[10:3] /

STID [2:0] /

RTR

IDE

EXID

 

EXID [14:7]

EXID[6:0]

0

 

FMHx = 0

 

FMHx = 1

EXID[28:21]

EXID[20:18]

[17:15]

 

 

FMLx = 0

 

FMLx = 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR1

CAN_FxR2

 

 

CAN_FxR3

CAN_FxR4

 

 

ID

n

 

ID

 

n

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR5

CAN_FxR6

 

 

CAN_FxR7

CAN_FxR8

 

 

M

 

ID

 

n+1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ID= Identifier

n = Filter number

 

 

 

 

 

 

 

 

 

 

 

 

 

M = Mask

x = Filter bank number

 

 

 

 

 

 

 

 

 

 

1 The FMHx and FMLx bits are located in the CAN_FMR1 and CAN_FMR2 registers

Figure 149. 16-bit filter bank configuration (FSCx bits = 0b10 in CAN_FCRx register)

 

Filter registers

 

 

 

 

 

 

 

 

 

Filter mode1

 

 

Mapping

STID[10:3] /

STID [2:0]

RTR

IDE

 

EXID

 

FMHx = 0

FMHx = 0

 

FMHx = 1

FMHx = 1

/ EXID

 

 

 

EXID[28:21]

 

[17:15]

 

FMLx = 0

FMLx = 1

 

FMLx = 0

FMLx = 1

 

 

[20:18]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR1

CAN_FxR2

 

 

ID

n

ID

n

 

ID

n

ID

n

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR3

CAN_FxR4

 

 

M

ID

n+1

 

M

ID

n+1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR5

CAN_FxR6

 

 

ID

n+1

ID

n+2

 

ID

n+1

ID

n+2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR7

CAN_FxR8

 

 

M

M

 

ID

n+2

ID

n+3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ID= Identifier

n = Filter number

 

 

 

 

 

 

 

 

 

 

 

 

M = Mask

x = Filter bank number

 

 

 

 

 

 

 

 

 

 

1 The FMHx and FMLx bits are located in the CAN_FMR1 and CAN_FMR2 registers

376/454

Doc ID 14587 Rev 9

RM0016

Controller area network (beCAN)

 

 

Figure 150. 16/8-bit filter bank configuration (FSCx bits = 0b01 in CAN_FCRx register)

 

Filter registers

 

 

 

 

 

 

 

 

Filter mode1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mapping

STID[10:3] /

STID [2:0]

RTR

IDE

EXID

 

FMHx = 0

FMHx = 0

 

FMHx = 1

 

FMHx = 1

/ EXID

 

 

 

EXID[28:21]

[17:15]

 

FMLx = 0

FMLx = 1

 

FMLx = 0

 

FMLx = 1

 

 

[20:18]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR1

CAN_FxR2

 

 

ID

n

ID

n

 

ID

 

n

 

ID

n

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR3

CAN_FxR4

 

 

M

ID

n+1

 

M

 

 

ID

n+1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR5

 

 

 

 

 

ID

n+1

ID

n+2

 

ID

 

n+1

 

ID

n+2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR6

 

 

 

 

 

M

M

 

ID

 

n+2

 

ID

n+3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR7

 

 

 

 

 

ID

n+2

ID

n+3

 

ID

 

n+3

 

ID

n+4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR8

 

 

 

 

 

M

M

 

ID

 

n+4

 

ID

n+5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ID= Identifier

n = Filter number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

M = Mask

x = Filter bank number

 

 

 

 

 

 

 

 

 

 

 

 

1 The FMHx and FMLx bits are located in the CAN_FMR1 and CAN_FMR2 registers

Figure 151. 8-bit filter bank configuration (FSCx bits = 0b00 in CAN_FCRx register)

 

Filter registers

 

 

 

 

 

 

 

Filter mode1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mapping

STID[10:3] /

 

FMHx = 0

 

 

FMHx = 0

 

FMHx = 1

 

FMHx = 1

EXID[28:21]

 

FMLx = 0

 

 

FMLx = 1

 

FMLx = 0

 

FMLx = 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR1

 

ID

n

 

 

ID

 

n

 

ID

 

n

 

ID

n

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR2

 

M

 

 

ID

 

n+1

 

M

 

 

ID

n+1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR3

 

ID

n+1

 

 

ID

 

n+2

 

ID

 

n+1

 

ID

n+2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR4

 

M

 

 

ID

 

n+3

 

M

 

 

ID

n+3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR5

 

ID

n+2

 

 

ID

 

n+4

 

ID

 

n+2

 

ID

n+4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR6

 

M

 

 

M

 

 

ID

 

n+3

 

ID

n+5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier

CAN_FxR7

 

ID

n+3

 

 

ID

 

n+5

 

ID

 

n+4

 

ID

n+6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Identifier/Mask

CAN_FxR8

 

M

 

 

M

 

 

ID

 

n+5

 

ID

n+7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ID= Identifier

 

n = Filter number

 

 

 

 

 

 

 

 

 

 

 

M = Mask

 

x = Filter bank number

 

 

 

 

 

 

 

 

1 The FMHx and FMLx bits are located in the CAN_FMR1 and CAN_FMR2 registers

Doc ID 14587 Rev 9

377/454

Controller area network (beCAN)

RM0016

 

 

Filter match index

Once a message has been received in the FIFO it is available to the application. Typically application data are copied into RAM locations. To copy the data to the right location the application has to identify the data by means of the identifier. To avoid this and to ease the access to the RAM locations, the CAN controller provides a Filter Match Index.

This index is stored in the mailbox together with the message according to the filter priority rules. Thus each received message has its associated Filter Match Index.

The Filter Match Index can be used in two ways:

Compare the Filter Match Index with a list of expected values.

Use the Filter Match Index as an index on an array to access the data destination location.

For non-masked filters, the software no longer has to compare the identifier.

If the filter is masked the software reduces the comparison to the masked bits only.

Note:

The index value of the filter number does not take into account the activation state of the

 

filter banks.

 

 

 

 

 

 

Table 65.

Example of filter numbering

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Filter bank

 

Filter number

 

 

 

 

 

 

 

 

 

Number

 

FCS

FMH

FML

FACT

Configuration

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0b11

1

1

1

Identifier list (32-bit)

0

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

0b11

0

0

1

Identifier mask (32-bit)

2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3

 

2

 

0b10

1

1

1

Identifier list (16-bit)

4

 

 

5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7

 

 

 

 

 

 

 

Deactivated

8

 

 

 

 

 

 

 

9

 

3

 

0b00

0

1

0

Identifier List/Identifier

 

 

10

 

 

 

 

 

 

 

mask (8-bit)

 

 

 

 

 

 

 

11

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

12

 

 

 

 

 

 

 

 

 

 

4

 

0b10

0

0

0

Deactivated

13

 

 

Identifier Mask (16-bit)

14

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

15

 

5

 

0b01

0

0

1

Identifier Mask (16/8-bit)

16

 

 

 

 

 

 

 

 

17

 

 

 

 

 

 

 

 

 

378/454

Doc ID 14587 Rev 9

Соседние файлы в папке Минимум документации STM8_1