STM32F1 CAN

Started by tha, January 29, 2021, 09:07:28 AM

Previous topic - Next topic

tha



Bits 31:6 Reserved, must be kept at reset value.

Bit 5 RFOM0: Release FIFO 0 output mailbox
เซ็ตโดย software เพื่อปลดปล่อย the output mailbox of the FIFO. The output mailbox สามารถถูกปลดปล่อยเฉพาะเมื่ออย่างน้อยหนึ่ง message กำลังค้างอยู่ใน the FIFO. การเซ็ตบิตนี้เมื่อ the FIFO ว่างเปล่าจะไม่มีผลอะไร. ถ้าอย่างน้อยสอง messages กำลังค้างอยู่ใน the FIFO, the software ต้องปลดปล่อย the output mailbox เพื่อเข้าถึง the next message.
ถูกเคลียร์โดย hardware เมื่อ the output mailbox ถูกปลดปล่อยแล้ว.

Bit 4 FOVR0: FIFO 0 overrun
บิตนี้ถูกเซ็ตโดย hardware เมื่อ a new message ถูกรับแล้วและผ่าน the filter ในขณะที่ the FIFO เต็มอยู่แล้ว.
บิตนี้ถูกเคลียร์โดย software

Bit 3 FULL0: FIFO 0 full
เซ็ตโดย hardware เมื่อ three messages ถูกเก็บใน the FIFO.
บิตนี้ถูกเคลียร์โดย software

Bit 2 Reserved, must be kept at reset value

Bits 1:0 FMP0[1:0]: FIFO 0 message pending
บิตเหล่านี้แสดงให้เห็นว่ามี messages จำนวนเท่าไหร่ที่กำลังค้างอยู่ใน the receive FIFO0. FMP0 เพิ่มขึ้นแต่ละครั้งที่ the hardware เก็บ a new message ลงใน the FIFO0. FMP0 ลดลงแต่ละครั้งที่ the software ปลดปล่อย the output mailbox โดยการเซ็ต the RFOM0 bit.

tha



Bits 31:6 Reserved, must be kept at reset value.

Bit 5 RFOM1: Release FIFO 1 output mailbox
เซ็ตโดย software เพื่อปลดปล่อย the output mailbox of the FIFO. The output mailbox สามารถถูกปลดปล่อยเฉพาะเมื่ออย่างน้อยหนึ่ง message กำลังค้างอยู่ใน the FIFO. การเซ็ตบิตนี้เมื่อ the FIFO ว่างเปล่าจะไม่มีผลอะไร. ถ้าอย่างน้อยสอง messages กำลังค้างอยู่ใน the FIFO, the software ต้องปลดปล่อย the output mailbox เพื่อเข้าถึง the next message.
ถูกเคลียร์โดย hardware เมื่อ the output mailbox ถูกปลดปล่อยแล้ว.

Bit 4 FOVR1: FIFO 1 overrun
บิตนี้ถูกเซ็ตโดย hardware เมื่อ a new message ถูกรับแล้วและผ่าน the filter ในขณะที่ the FIFO เต็มอยู่แล้ว.
บิตนี้ถูกเคลียร์โดย software

Bit 3 FULL1: FIFO 1 full
เซ็ตโดย hardware เมื่อ three messages ถูกเก็บใน the FIFO.
บิตนี้ถูกเคลียร์โดย software

Bit 2 Reserved, must be kept at reset value

Bits 1:0 FMP1[1:0]: FIFO 1 message pending
บิตเหล่านี้แสดงให้เห็นว่ามี messages จำนวนเท่าไหร่ที่กำลังค้างอยู่ใน the receive FIFO1. FMP1 เพิ่มขึ้นแต่ละครั้งที่ the hardware เก็บ a new message ลงใน the FIFO1. FMP1 ลดลงแต่ละครั้งที่ the software ปลดปล่อย the output mailbox โดยการเซ็ต the RFOM1 bit.

tha



Bits 31:18 Reserved, must be kept at reset value.

Bit 17 SLKIE: Sleep interrupt enable
     0: ไม่มี interrupt เมื่อ SLAKI bit ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ SLAKI bit ถูกเซ็ต.

Bit 16 WKUIE: Wakeup interrupt enable
     0: ไม่มี interrupt เมื่อ WKUI ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ WKUI bit ถูกเซ็ต.

Bit 15 ERRIE: Error interrupt enable
     0: ไม่มี interrupt จะถูกสร้างขึ้นเมื่อ an error condition กำลังค้างอยู่ใน the CAN_ESR.
     1: An interrupt จะถูกสร้างขึ้นเมื่อ an error condition กำลังค้างอยู่ใน the CAN_ESR.

Bits 14:12 Reserved, must be kept at reset value.

Bit 11 LECIE: Last error code interrupt enable
     0: ERRI bit จะไม่ถูกเซ็ตเมื่อ the error code ใน LEC[2:0] ถูกเซ็ตโดย hardware บน error detection.
     1: ERRI bit จะถูกเซ็ตเมื่อ the error code ใน LEC[2:0] ถูกเซ็ตโดย hardware บน error detection.

Bit 10 BOFIE: Bus-off interrupt enable
     0: ERRI bit จะไม่ถูกเซ็ตเมื่อ BOFF ถูกเซ็ต
     1: ERRI bit จะถูกเซ็ตเมื่อ BOFF ถูกเซ็ต

Bit 9 EPVIE: Error passive interrupt enable
     0: ERRI bit จะไม่ถูกเซ็ตเมื่อ EPVF ถูกเซ็ต
     1: ERRI bit จะถูกเซ็ตเมื่อ EPVF ถูกเซ็ต

Bit 8 EWGIE: Error warning interrupt enable
     0: ERRI bit จะไม่ถูกเซ็ตเมื่อ EWGF ถูกเซ็ต
     1: ERRI bit จะถูกเซ็ตเมื่อ EWGF ถูกเซ็ต

Bit 7 Reserved, must be kept at reset value.

Bit 6 FOVIE1: FIFO overrun interrupt enable
     0: ไม่มี interrupt เมื่อ FOVR ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ FOVR ถูกเซ็ต.

Bit 5 FFIE1: FIFO full interrupt enable
     0: ไม่มี interrupt เมื่อ FULL bit ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ FULL bit ถูกเซ็ต

Bit 4 FMPIE1: FIFO message pending interrupt enable
     0: ไม่มี interrupt ถูกสร้างขึ้นเมื่อสถานะของ FMP[1:0] bits ไม่เป็น 00b.
     1: Interrupt ถูกสร้างขึ้นเมื่อสถานะของ FMP[1:0] bits ไม่เป็น 00b.

Bit 3 FOVIE0: FIFO overrun interrupt enable
     0: ไม่มี interrupt เมื่อ FOVR ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ FOVR ถูกเซ็ต.

Bit 2 FFIE0: FIFO full interrupt enable
     0: ไม่มี interrupt เมื่อ FULL bit ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ FULL bit ถูกเซ็ต

Bit 1 FMPIE0: FIFO message pending interrupt enable
     0: ไม่มี interrupt ถูกสร้างขึ้นเมื่อสถานะของ FMP[1:0] bits ไม่เป็น 00b.
     1: Interrupt ถูกสร้างขึ้นเมื่อสถานะของ FMP[1:0] bits ไม่เป็น 00b.

Bit 0 TMEIE: Transmit mailbox empty interrupt enable
     0: ไม่มี interrupt เมื่อ RQCPx bit ถูกเซ็ต.
     1: Interrupt ถูกสร้างขึ้นเมื่อ RQCPx bit ถูกเซ็ต
Note: Refer to Section 24.8: bxCAN interrupts.


tha



Bits 31:24 REC[7:0]: Receive error counter
ส่วนที่มีให้ใช้งานของ the fault confinement mechanism ของ the CAN protocol. ในกรณีของ an error ในระหว่าง reception, ตัวนับนี้ถูกเพิ่มขึ้น 1 หรือ 8 ขึ้นอยู่กับ the error condition ตามที่กำหนดโดย the CAN standard. หลังจากทุกๆ reception ที่สำเร็จลง the counter ถูกลดลง 1 หรือรีเซ็ตไปเป็น 120 ถ้าค่าของมันสูงกว่า 128. เมื่อ the counter value เกิน 127, the CAN controller จะเข้าสู่ the error passive state.

Bits 23:16 TEC[7:0]: Least significant byte of the 9-bit transmit error counter
ส่วนที่มีให้ใช้งานของ the fault confinement mechanism ของ the CAN protocol.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:4 LEC[2:0]: Last error code
field นี้ถูกเซ็ตโดย hardware และจับยึด a code ซึ่งแสดงให้เห็น the error condition ของ the last error ที่ตรวจพบบน the CAN bus. ถ้า a message ถูกส่งถ่ายแล้ว (reception or transmission) โดยไม่มี error, field นี้จะถูกเคลียร์เป็น '0'.
The LEC[2:0] bits สามารถถูกเซ็ตเป็นค่า 0b111 โดย software. พวกมันถูกอัปเดตโดย hardware เพื่อแสดงให้เห็น the current communication status.
     000: No Error
     001: Stuff Error
     010: Form Error
     011: Acknowledgment Error
     100: Bit recessive Error
     101: Bit dominant Error
     110: CRC Error
     111: Set by software

Bit 3 Reserved, must be kept at reset value

Bit 2 BOFF: Bus-off flag
บิตนี้ถูกเซ็ตโดย hardware เมื่อมันเข้าสู่ the bus-off state. The bus-off state ถูกเข้าสู่บน TEC overflow, ที่มากกว่า 255, อ้างอิงถึง Section 24.7.6.

Bit 1 EPVF: Error passive flag
บิตนี้ถูกเซ็ตโดย hardware เมื่อ the Error Passive limit ถูกถึงแล้ว (Receive Error Counter หรือ Transmit Error Counter>127).

Bit 0 EWGF: Error warning flag
บิตนี้ถูกเซ็ตโดย hardware เมื่อ the warning limit ถูกถึงแล้ว (Receive Error Counter หรือ Transmit Error Counter≥96).

tha



Bit 31 SILM: Silent mode (debug)
     0: Normal operation
     1: Silent Mode

Bit 30 LBKM: Loop back mode (debug)
     0: Loop Back Mode ถูกปิดการใช้งาน
     1: Loop Back Mode ถูกเปิดการใช้งาน

Bits 29:26 Reserved, must be kept at reset value.

Bits 25:24 SJW[1:0]: Resynchronization jump width
บิตเหล่านี้กำหนดจำนวนสูงสุดของ time quanta ที่ the CAN hardware ถูกยอมให้ยาวขึ้นหรือสั้นลงเล็กน้อยเพื่อดำเนินการ the resynchronization.


Bit 23 Reserved, must be kept at reset value.

Bits 22:20 TS2[2:0]: Time segment 2
บิตเหล่านี้กำหนดจำนวนของ time quanta ใน Time Segment 2.


Bits 19:16 TS1[3:0]: Time segment 1
บิตเหล่านี้กำหนดจำนวนของ time quanta ใน Time Segment 1

สำหรับข้อมูลที่มากขึ้นบน bit timing อ้างอิงถึง Section 24.7.7.

Bits 15:10 Reserved, must be kept at reset value.

Bits 9:0 BRP[9:0]: Baud rate prescaler
บิตเหล่านี้กำหนด the length of a time quanta.

tha

24.9.3 CAN mailbox registers

บทนี้อธิบาย the registers ของ the transmit and receive mailboxes. อ้างอิงถึง Section 24.7.5: Message storage สำหรับรายละเอียด register mapping.

Transmit และ receive mailboxes มี the same registers ยกเว้น:
•    The FMI field ใน the CAN_RDTxR register.
•    A receive mailbox ถูกป้องกันการเขียนเสมอ.
•    A transmit mailbox ถูก write-enabled เฉพาะในขณะที่ว่างเปล่า, corresponding TME bit ใน the CAN_TSR register เซ็ต.

มี three TX Mailboxes และ two RX Mailboxes , ดังแสดงใน Figure 237. แต่ละ RX Mailbox ยอมให้เข้าถึงไปยัง a 3-level depth FIFO, การเข้าถึงถูกเสนอเฉพาะถึง the oldest received message ใน the FIFO. แต่ละ mailbox ประกอบด้วย four registers.


tha

CAN TX mailbox identifier register (CAN_TIxR) (x=0..2)

Address offsets: 0x180, 0x190, 0x1A0
Reset value: 0xXXXX XXXX (except bit 0, TXRQ = 0)

ทุก TX registers ถูกป้องกันการเขียนเมื่อ the mailbox กำลังค้างอยู่ transmission (TMEx reset).
register นี้จัดให้มีใช้ the TX request control (bit 0) อีกด้วย - reset value 0.



Bits 31:21 STID[10:0]/EXID[28:18]: Standard identifier or extended identifier
The standard identifier หรือ the MSBs of the extended identifier (ขึ้นอยู่กับ the IDE bit value).

Bits 20:3 EXID[17:0]: Extended identifier
The LSBs of the extended identifier.

Bit 2 IDE: Identifier extension
บิตนี้กำหนด the identifier type ของ message ใน the mailbox.
     0: Standard identifier.
     1: Extended identifier.

Bit 1 RTR: Remote transmission request
     0: Data frame
     1: Remote frame

Bit 0 TXRQ: Transmit mailbox request
เซ็ตโดย software เพื่อร้องขอ the transmission สำหรับ the corresponding mailbox.
เคลียร์โดย hardware เมื่อ the mailbox มาเป็น empty.

tha

CAN mailbox data length control and time stamp register (CAN_TDTxR) (x=0..2)

ทุกบิตของ register นี้ถูกป้องกันการเขียนเมื่อ the mailbox ไม่อยู่ใน empty state.

Address offsets: 0x184, 0x194, 0x1A4
Reset value: 0xXXXX XXXX



Bits 31:16 TIME[15:0]: Message time stamp
field นี้บรรจุ the 16-bit timer value ที่ถูกจับที่ the SOF transmission.

Bits 15:9 Reserved, must be kept at reset value.

Bit 8 TGT: Transmit global time
บิตนี้จะ active เฉพาะเมื่อ the hardware อยู่ใน the Time Trigger Communication mode, TTCM bit ของ the CAN_MCR register ถูกเซ็ต.
     0: Time stamp TIME[15:0] ไม่ถูกส่ง.
     1: Time stamp TIME[15:0] value ถูกส่งใน the last two data bytes ของ the 8-byte message:
         TIME[7:0] ใน data byte 7 และ TIME[15:8] ใน data byte 6, แทนที่ the data ที่ถูกเขียนใน CAN_TDHxR[31:16]
         register (DATA6[7:0] and DATA7[7:0]). DLC ต้องถูกโปรแกรมเป็น 8 เพื่อให้ two bytes นี้ถูกส่งไปบน the CAN bus.

Bits 7:4 Reserved, must be kept at reset value.

Bits 3:0 DLC[3:0]: Data length code
field นี้กำหนดจำนวนของ data bytes ที่มี a data frame บรรจุอยู่หรือมีการร้องขอ a remote frame. A message สามารถบรรจุจาก 0 ถึง 8 data bytes, ขึ้นอยู่กับค่าใน the DLC field.