Electoday 2025

ไมโครคอนโทรลเลอร์ => ARM Processors => Topic started by: tha on January 29, 2021, 09:07:28 AM

Title: STM32F1 CAN
Post by: tha on January 29, 2021, 09:07:28 AM
24 Controller area network (bxCAN)

Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

ส่วนนี้ใช้กับ the connectivity line and STM32F103xx performance line เท่านั้น.

24.1 bxCAN introduction

The Basic Extended CAN peripheral, ชื่อ bxCAN, เชื่อมต่อ the CAN network. มันรองรับ the CAN protocols version 2.0A and B. มันถูกออกแบบเพื่อจัดการ a high number of incoming messages อย่างมีประสิทธิภาพด้วย a minimum CPU load. มันตรงตาม the priority requirements สำหรับ transmit messages อีกด้วย.

สำหรับ safety-critical applications, the CAN controller จัดให้มีทุก hardware functions สำหรับการรองรับ the CAN Time Triggered Communication option.
Title: Re: STM32F1 CAN
Post by: tha on January 29, 2021, 11:12:38 AM
24.2 bxCAN main features

•    รองรับ CAN protocol version 2.0 A, B Active
•    Bit rates สูงถึง 1 Mbit/s
•    รองรับ the Time Triggered Communication option

Transmission

•    3 transmit mailboxes
•    กำหนดค่าได้ transmit priority
•    Time Stamp on SOF transmission

Reception

•    2 receive FIFOs พร้อมด้วย 3 stages
•    ปรับขนาดได้ filter banks:
     –    28 filter banks ใช้ร่วมกันระหว่าง CAN1 and CAN2 ใน connectivity line devices
     –    14 filter banks ใน STM32F10xxx devices อื่นๆ
•    Identifier list คุณลักษณะ
•    กำหนดค่าได้ FIFO overrun
•    Time Stamp on SOF reception

Time-triggered communication option

•    ปิดการใช้งาน automatic retransmission mode
•    16-bit free running timer
•    Time Stamp ส่งใน last two data bytes

Management

•    Maskable(บังได้) interrupts
•    Software-efficient mailbox แม็ปที่ a unique address space

Dual CAN

•    CAN1: Master bxCAN สำหรับจัดการ the communication ระหว่าง a Slave bxCAN และ the 512-byte SRAM memory
•    CAN2: Slave bxCAN, พร้อมด้วยไม่มีการเข้าถึงโดยตรงไปยัง the SRAM memory.
•    The two bxCAN cells ใช้ร่วมกัน the 512-byte SRAM memory (ดู Figure 223)

Note: In low, medium-, high- and XL-density devices the USB and CAN ใช้ร่วมกัน a dedicated 512-byte SRAM
           memory สำหรับ data transmission and reception, และดังนั้นพวกมันไม่สามารถถูกใช้พร้อมกันy (the shared SRAM ถูก
           เข้าถึงผ่านทาง CAN and USB อย่างเฉพาะตัว). The USB and CAN สามารถถูกใช้ใน the same application แต่ไม่ในเวลา
           เดียวกัน.
Title: Re: STM32F1 CAN
Post by: tha on January 30, 2021, 07:11:23 AM
24.3 bxCAN general description

ใน CAN applications ปัจจุบันนี้, จำนวนของ nodes ใน a network กำลังเพิ่มขึ้นและบ่อยครั้งหลาย networks ถูกเชื่อมต่อเข้าด้วยกันโดยทาง gateways. โดยทั่วไปจำนวนของ messages ใน the system (และดังนั้นถูกรับมือโดยแต่ละ node) ถูกเพิ่มขึ้นอย่างมีนัยสำคัญ. นอกจากนี้ the application messages, Network Management and Diagnostic messages ถูกแนะนำมา.
•    An enhanced filtering mechanism ถูกต้องการเพื่อรับมือแต่ละชนิดของ message.

นอกจากนี้, application tasks ต้องการ CPU time ที่มากขึ้น, ดังนั้น real-time constraints ที่มีสาเหตุโดย message reception ต้องถูกลดลง.
•    A receive FIFO scheme ยอมให้ the CPU ทุ่มเทให้กับ application tasks เป็นเวลา a long time period โดยปราศจาก losing
      messages.

The standard HLP (Higher Layer Protocol) ที่ใช้ standard CAN drivers ต้องการอินเตอร์เฟซที่มีประสิทธิภาพไปยัง the CAN controller.

(https://i.imgur.com/57rjFFf.png)
Title: Re: STM32F1 CAN
Post by: tha on January 30, 2021, 08:00:43 AM
24.3.1 CAN 2.0B active core

The bxCAN module จัดการ the transmission and the reception of CAN messages อย่างเต็มที่โดยอัตโนมัติ. Standard identifiers (11-bit) and extended identifiers (29-bit) ถูกรองรับอย่างเต็มที่โดย hardware.

24.3.2 Control, status and configuration registers

The application ใช้ registers เหล่านี้เพื่อ:
•    Configure CAN parameters, อย่างเช่น baud rate
•    Request transmissions
•    Handle receptions
•    Manage interrupts
•    Get diagnostic information
Title: Re: STM32F1 CAN
Post by: tha on January 30, 2021, 09:58:22 AM
24.3.3 Tx mailboxes

Three transmit mailboxes ถูกจัดให้กับ the software สำหรับตั้งค่า messages. The transmission Scheduler ตัดสินว่า mailbox ใดต้องถูกส่งเป็นอันดับแรก

24.3.4 Acceptance filters

The bxCAN จัดให้มี 28 scalable/configurable identifier filter banks สำหรับการเลือก the incoming messages ที่ the software ต้องการและละทิ้งข้อความอื่น. ใน devices อื่นจะมี 14 scalable/configurable identifier filter banks.

Receive FIFO

Two receive FIFOs ถูกใช้โดย hardware เพื่อเก็บ the incoming messages. Three complete messages สามารถถูกเก็บในแต่ละ FIFO. The FIFOs ถูกจัดการอย่างสมบูรณ์โดย hardware.

(https://i.imgur.com/gPeTagR.png)
Title: Re: STM32F1 CAN
Post by: tha on January 30, 2021, 02:20:51 PM
24.4 bxCAN operating modes

bxCAN มี three main operating modes: initialization, normal and Sleep. หลังจาก a hardware reset, bxCAN อยู่ใน Sleep mode เพื่อลด power consumption และ an internal pullup จะ active บน CANTX. The software ร้องขอ bxCAN เพื่อเข้าสู่ initialization หรือ Sleep mode โดยการเซ็ต the INRQ หรือ SLEEP bits ใน the CAN_MCR register. เมื่อ the mode นั้นได้ถูกเข้าสู่แล้ว, bxCAN ยืนยันมันโดยการเซ็ต the INAK หรือ SLAK bits ใน the CAN_MSR register และ the internal pull-up ถูกปิดการใช้งาน. เมื่อไม่มี INAK หรือ SLAK ถูกเซ็ต, bxCAN อยู่ใน normal mode. ก่อนการเข้าสู่ normal mode bxCAN ต้อง synchronize เสมอบน the CAN bus. เพื่อ synchronize, bxCAN คอยจนกระทั่ง the CAN bus เป็น idle, นี้หมายถึง 11 consecutive recessive bits ถูกมอนิเตอร์แล้วบน CANRX.
Title: Re: STM32F1 CAN
Post by: tha on January 31, 2021, 06:34:04 AM
24.4.1 Initialization mode

The software initialization สามารถถูกทำในขณะที่ the hardware อยู่ใน Initialization mode. เพื่อเข้าสู่โหมดนี้ the software เซ็ต the INRQ bit ใน the CAN_MCR register และคอยจนกระทั่ง the hardware ถูกยืนยันการร้องขอโดยการเซ็ต the INAK bit ใน the CAN_MSR register.

เพื่อออกจาก Initialization mode, the software เคลียร์ the INQR bit. bxCAN ถูกออกจาก Initialization mode เมื่อ the INAK bit ถูกเคลียร์แล้วโดย hardware.

ขณะใน Initialization Mode, message ทั้งหมดส่งถ่ายถึงและจาก the CAN bus ถูกหยุดและสถานะของ the CAN bus output CANTX ถอน (high).

การเข้าสู่ Initialization Mode ไม่ได้เปลี่ยนแปลง the configuration registers ใดๆ.

เพื่อเริ่มต้น the CAN Controller, software ต้องตั้งค่า the Bit Timing (CAN_BTR) และ CAN options (CAN_MCR) registers

เพื่อเริ่มต้น the registers ที่เกี่ยวข้องกับ the CAN filter banks (mode, scale, FIFO การกำหนดค่า, การเปิดใช้งาน และ filter values), software ต้องเซ็ต the FINIT bit (CAN_FMR). Filter initialization สามารถถูกทำภายนอก the initialization mode ได้อีกด้วย.

Note: เมื่อ FINIT=1, CAN reception จะถูกปิดใช้งาน

            The filter values สามารถถูกแก้ไขโดยปิดใช้งาน the associated filter activation bits (ใน the CAN_FA1R register)
            ได้อีกด้วย.

             ถ้า a filter bank ไม่ถูกใช้, ขอแนะนำให้ปล่อยมันไม่ให้ทำงาน (ปล่อยให้ the corresponding FACT bit เคลียร์).
Title: Re: STM32F1 CAN
Post by: tha on January 31, 2021, 08:49:02 AM
24.4.2 Normal mode

เมื่อ the initialization เสร็จสมบูรณ์, the software ต้องร้องอ the hardware เพื่อเข้าสู่ Normal mode เพื่อให้สามารถ synchronize บน the CAN bus และสตาร์ท reception and transmission.

การร้องขอเพื่อเข้าสู่ Normal mode ถูกปล่อยออกโดยการเคลียร์ the INRQ bit ใน the CAN_MCR register. The bxCAN เข้าสู่ Normal mode และพร้อมที่จะมีส่วนร่วมใน bus activities เมื่อมันได้ synchronized กับ the data transfer บน the CAN bus. นี้ทำได้โดยการรอการเกิดลำดับของ 11 consecutive recessive bits (Bus Idle state). การสวิทช์ไปยัง Normal mode ถูกยืนยันโดย the hardware โดยการเคลียร์ the INAK bit in the CAN_MSR register.

การเริ่มต้นของ the filter values เป็นอิสระจาก Initialization Mode แต่ต้องถูกทำในขณะที่ the filter ไม่ active (corresponding FACTx bit ถูกเคลียร์). The filter scale และ mode configuration ต้องถูกกำหนดค่าก่อนการเข้าสู่ Normal Mode.
Title: Re: STM32F1 CAN
Post by: tha on January 31, 2021, 10:15:11 AM
24.4.3 Sleep mode (low power)

เพื่อลด power consumption, bxCAN มี a low-power mode ที่เรียกว่า Sleep mode. โหมดนี้ถูกเข้าสู่บน software ร้องขอโดยการเซ็ต the SLEEP bit in the CAN_MCR register. ในโหมดนี้, the bxCAN clock ถูกหยุด, อย่างไรก็ตาม software สามารถยังคงเข้าถึง the bxCAN mailboxes.

ถ้า software ร้องขอเข้าสู่ไปยัง initialization mode โดยการเซ็ต the INRQ bit ในขณะที่ bxCAN อยู่ใน Sleep mode, มันต้องเคลียร์ the SLEEP bit ด้วย.

bxCAN สามารถถูกปลูก (ออกจาก Sleep mode) อย่างใดอย่างหนึ่งโดย software การเคลียร์ the SLEEP bit หรือบนการตรวจพบของ CAN bus activity

บน CAN bus activity detection, hardware ดำเนินการ the wakeup sequence โดยอัตโนมัติโดยการเคลียร์ the SLEEP bit ถ้า the AWUM bit ใน the CAN_MCR register ถูกเซ็ต. ถ้า the AWUM bit ถูกเคลียร์, software ต้องเคลียร์ the SLEEP bit เมื่อ a wakeup interrupt เกิดขึ้น, เพื่อออกจาก Sleep mode.

Note: ถ้า the wakeup interrupt ถูกเปิดการใช้งาน (WKUIE bit ถูกเซ็ตใน CAN_IER register) a wakeup interrupt จะถูกสร้าง
           ขึ้นบนการตรวจพบของ CAN bus activity, ถึงแม้ว่า the bxCAN ดำเนินการ the wakeup sequence โดยอัตโนมัติ.

หลังจาก the SLEEP bit ถูกเคลียร์แล้ว, Sleep mode ถูก exited เมื่อ bxCAN ได้ synchronized กับ the CAN bus, อ้างอิงถึง Figure 224. The Sleep mode ถูก exited เมื่อ the SLAK bit ถูกเคลียร์แล้วโดย hardware.

(https://i.imgur.com/E5EHjiy.png)

1. ACK = The wait state ในระหว่างที่ hardware ยืนยัน a request โดยการเซ็ต the INAK or SLAK bits in the CAN_MSR register
2. SYNC = The state ในระหว่างที่ bxCAN คอยจนกระทั่ง the CAN bus อยู่ idle, ซึงหมายถึง 11 consecutive recessive bits ถูกมอนิเตอร์แล้วบน CANRX
Title: Re: STM32F1 CAN
Post by: tha on January 31, 2021, 03:48:28 PM
24.5 Test mode

Test mode สามารถถูกเลือกโดย the SILM and LBKM bits in the CAN_BTR register. บิตเหล่านี้ต้องถูกกำหนดค่าขณะที่ bxCAN อยู่ใน Initialization mode. เมื่อ test mode ถูกเลือกแล้ว, the INRQ bit in the CAN_MCR register ต้องถูกรีเซ็ตเพื่อเข้าสู่ Normal mode.

24.5.1 Silent mode

The bxCAN สามารถถูกใส่ใน Silent mode โดยการเซ็ต the SILM bit in the CAN_BTR register.

ใน Silent mode, the bxCAN สามารถที่จะรับ valid data frames และ valid remote frames, แต่มันส่งเฉพาะ recessive bits บน the CAN bus และมันไม่สามารถสตาร์ท a transmission. ถ้า the bxCAN ต้องส่ง a dominant bit (ACK bit, overload flag, active error flag), the bit จะถูกกำหนดเส้นทางใหม่ภายในเพื่อว่า the CAN Core มอนิเตอร์ dominant bit นี้, แม้ว่า the CAN bus อาจยังคงอยู่ใน recessive state. Silent mode สามารถถูกใช้วิเคราะห์การจราจรบน a CAN bus ไม่มีผลกระทบมันโดยการส่งของ dominant bits (Acknowledge Bits, Error Frames).

(https://i.imgur.com/wGPLums.png)
Title: Re: STM32F1 CAN
Post by: tha on February 01, 2021, 07:16:43 AM
24.5.2 Loop back mode

The bxCAN สามารถถูกเซ็ตใน Loop Back Mode โดยการเซ็ต the LBKM bit in the CAN_BTR register. ใน Loop Back Mode, the bxCAN ปฏิบัติต่อ transmitted messages ของตัวเองดัง received messages และเก็บพวกมัน (ถ้าพวกมันผ่านการยอมรับการกรอง) ใน a Receive mailbox.

(https://i.imgur.com/hFOw2DR.png)

โหมดนี้ถูกจัดให้มีสำหรับ self-test functions. เพื่อให้เป็นอิสระจาก external events, the CAN Core จะเพิกเฉยต่อ acknowledge errors (ไม่มี dominant bit ถูกสุ่มใน the acknowledge slot ของ a data / remote frame) ใน Loop Back Mode. ในโหมดนี้, the bxCAN ดำเนินการป้อนกลับภายในจาก Tx output ของมันไปยัง Rx input ของมัน. ค่าจริงของ the CANRX input pin ถูกมองข้ามโดย the bxCAN. The transmitted messages สามารถถูกมอนิเตอร์บน the CANTX pin.
Title: Re: STM32F1 CAN
Post by: tha on February 01, 2021, 07:18:25 AM
24.5.3 Loop back combined with silent mode

มันเป็นไปได้ที่จะรวม Loop Back mode และ Silent mode ได้อีกด้วยโดยการเซ็ต the LBKM และ SILM bits in the CAN_BTR register. โหมดนี้สามารถถูกใช้สำหรับ a "Hot Selftest", หมายความว่า the bxCAN สามารถถูกทดสอบเหมือนใน Loop Back mode แต่ไม่มีผลกระทบกับ a running CAN system ที่ต่อถึง the CANTX and CANRX pins. ในโหมดนี้, the CANRX pin จะถูกตัดการเชื่อมต่อจาก the bxCAN และ the CANTX pin ถูกยึด recessive.

(https://i.imgur.com/7v8V5FK.png)
Title: Re: STM32F1 CAN
Post by: tha on February 01, 2021, 09:00:51 AM
24.6 Debug mode

เมื่อ the microcontroller เข้าสู่ the debug mode (Cortex®-M3 core ถูกหยุด), the bxCAN ยังคงทำงานต่อไปโดยปกติหรือหยุด, ขึ้นอยู่กับ:
•    the DBG_CAN1_STOP bit สำหรับ CAN1 หรือ the DBG_CAN2_STOP bit สำหรับ CAN2 ใน the DBG module. สำหรับราย
      ละเอียดที่มากขึ้น, อ้างอิงถึง Section 31.16.2: Debug support for timers, watchdog, bxCAN and I2C.
•    the DBF bit in CAN_MCR. สำหรับรายละเอียดที่มากขึ้น, อ้างอิงถึง Section 24.9.2.
Title: Re: STM32F1 CAN
Post by: tha on February 01, 2021, 03:13:48 PM
24.7 bxCAN functional description

24.7.1 Transmission handling

เพื่อส่ง a message, the application ต้องเลือก one empty transmit mailbox, ตั้งค่า the identifier, the data length code (DLC) และ the data ก่อนการร้องขอ the transmission โดยการเซ็ต the corresponding TXRQ bit ใน the CAN_TIxR register. เมื่อ the mailbox ออกจาก empty state แล้ว, the software ไม่สามารถเขียนเข้าถึงไปยัง the mailbox registers ได้อีกต่อไป. ทันทีหลังจาก the TXRQ bit ถูกเซ็ตแล้ว, the mailbox เข้าสู่ pending state และคอยมาเป็น the highest priority mailbox, ดู Transmit Priority. ทันทีที่ the mailbox มี the highest priority มันจะถูกวาง scheduled สำหรับ transmission. The transmission ของ the message ของ the scheduled mailbox จะสตาร์ท (เข้าสู่ transmit state) เมื่อ the CAN bus มาเป็น idle. เมื่อ the mailbox ถูกส่งสำเร็จแล้ว, มันจะมาเป็น empty อีกครั้ง. The hardware จะแสดงให้เห็นว่า a successful transmission โดยการเซ็ต the RQCP และ TXOK bits ใน the CAN_TSR register.

ถ้า the transmission ล้มเหลว, สาเหตุถูกแสดงให้เห็นโดย the ALST bit in the CAN_TSR register ในกรณีของ an Arbitration Lost, และ/หรือ the TERR bit, ในกรณีของ transmission error detection.
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 07:25:17 AM
Transmit priority

By identifier                           เมื่อมากกว่า one transmit mailbox ถูก pending, the transmission order ถูกให้โดย the
                                                identifier ของ the message ที่ถูกเก็บใน the mailbox. The message ที่มี the lowest
                                                identifier value จะมี the highest priority สอดคล้องกันกับ the arbitration ของ the CAN
                                                protocol. ถ้า the identifier values เท่ากัน, the lower mailbox number จะถูก
                                                scheduled ก่อน.

By transmit request order    The transmit mailboxes สามารถถูกกำหนดค่าเป็น a transmit FIFO โดยการเซ็ต the TXFP bit
                                                  ใน the CAN_MCR register. ในโหมดนี้ the priority order ถูกให้โดย the transmit
                                                  request order. โหมดนี้มีประโยชน์มากสำหรับ segmented transmission.
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 08:24:27 AM
Abort

A transmission request สามารถถูกยกเลิกโดย the user เซ็ต the ABRQ bit ใน the CAN_TSR register. ใน pending หรือ scheduled state, the mailbox จะถูกยกเลิกโดยทันที. An abort request ในขณะที่ the mailbox อยู่ใน transmit state สามารถมีสองผล. ถ้า the mailbox ถูกส่งสำเร็จ the mailbox มาเป็น empty พร้อมด้วย the TXOK bit set ใน the CAN_TSR register. ถ้า the transmission ล้มเหลว, the mailbox มาเป็น scheduled, the transmission ถูกยกเลิกและมาเป็น empty พร้อมด้วย TXOK cleared. ในทุกกรณี the mailbox จะมาเป็น empty อีกครั้งอย่างน้อยที่ the end of the current transmission.
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 09:31:32 AM
Nonautomatic retransmission mode

โหมดนี้ถูกมีให้ใช้เพื่อเติมเต็มความต้องการของ the Time Triggered Communication option ของ the CAN standard. เพื่อกำหนดค่า the hardware ในโหมดนี้ the NART bit in the CAN_MCR register ต้องถูกเซ็ต.

ในโหมดนี้, แต่ละ transmission ถูกสตาร์ทเพียงครั้งเดียว. ถ้า the first attempt ล้มเหลว, เนื่องจาก an arbitration loss หรือ an error, the hardware จะไม่รีสตาร์ท  the message transmission โดยอัตโนมัติ.

ที่ the end of the first transmission attempt, the hardware พิจารณา the request ว่าเสร็จสมบูรณ์และเซ็ต the RQCP bit ใน the CAN_TSR register. The result of the transmission ถูกแสดงให้เห็นใน the CAN_TSR register โดย the TXOK, ALST and TERR bits.

(https://i.imgur.com/04Y69ef.png)
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 02:14:01 PM
24.7.2 Time triggered communication mode

ในโหมดนี้, the internal counter ของ the CAN hardware ถูกทำให้ทำงานและใช้สร้าง the Time Stamp value ที่เก็บไว้ใน the CAN_RDTxR/CAN_TDTxR registers, ตามลำดับ (สำหรับ Rx และ Tx mailboxes). The internal counter ถูกเพิ่มขึ้นแต่ละ CAN bit time (อ้างอิงถึง Section 24.7.7). The internal counter ถูก captured บน the sample point ของ the Start Of Frame bit ในทั้ง reception and transmission.
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 03:49:10 PM
24.7.3 Reception handling

สำหรับ the reception ของ CAN messages, three mailboxes ที่จัดระบบเป็น a FIFO ถูกจัดให้มี. เพื่อประหยัด CPU load, ความง่ายของ the software และรับประกันความสม่ำเสมอของ data , the FIFO ถูกจัดการอย่างสมบูรณ์โดย hardware. The application เข้าถึง the messages ที่เก็บไว้ใน the FIFO ผ่านทาง the FIFO output mailbox.

Valid message

A received message ถูกพิจารณาว่าใช้ได้เมื่อมันถูกรับอย่างถูกต้องแล้วสอดคล้องกับ the CAN protocol (ไม่มี error จนกระทั่งสุดท้ายแต่ one bit of the EOF field) และมันผ่านๆทาง the identifier filtering สำเร็จ, ดู Section 24.7.4.
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 04:15:28 PM
(https://i.imgur.com/qSRlLrv.png)

FIFO management

สตาร์ทจาก the empty state, the first valid message received ถูกเก็บใน the FIFO ซึ่งมาเป็น pending_1. The hardware ให้สัญญาณเหตุการณ์นี้โดยการเซ็ต the FMP[1:0] bits ใน the CAN_RFR register เป็นค่า 01b. The message มีให้ใช้ใน the FIFO output mailbox. The software อ่านออก the mailbox content และปลดปล่อยมันโดยการเซ็ต the RFOM bit ใน the CAN_RFR register. The FIFO มาเป็น empty อีกครั้ง. ถ้า a new valid message ถูกรับแล้วในระหว่างนี้, the FIFO อยู่ใน pending_1 state และ the new message มีให้ใช้ใน the output mailbox.

ถ้า the application ไม่ปลดปล่อย the mailbox, the next valid message จะถูกเก็บใน the FIFO ซึ่งเข้าสู่ pending_2 state (FMP[1:0] = 10b). The storage process ถูกซ้ำสำหรับ the next valid message โดยการผลัก the FIFO ลงใน pending_3 state (FMP[1:0] = 11b). ที่จุดนี้, the software ต้องปลดปล่อย the output mailbox โดยการเซ็ต the RFOM bit, ดังนั้น a
mailbox ถูกปล่อยเป็นอิสระเพื่อเก็บ the next valid message. มิฉะนั้น the next valid message received จะเป็นเหตุให้ a loss of message.

อ้างอิงถึง Section 24.7.5 อีกด้วย
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 05:06:48 PM
Overrun

เมื่อ the FIFO อยู่ใน pending_3 state (เช่น the three mailboxes เต็ม) the next valid message reception จะนำไปสู่ an overrun และ a message จะสูญหาย. The hardware ให้สัญญาณ the overrun condition โดยการเซ็ต the FOVR bit ใน the CAN_RFR register. ซึ่ง message ที่สูญหายขึ้นอยู่กับ the configuration of the FIFO:
•    ถ้า the FIFO lock function ถูกปิดการใช้งาน (RFLM bit in the CAN_MCR register เคลียร์) the last message ที่เก็บใน the
      FIFO จะถูกเขียนทับโดย the new incoming message. ในกรณีนี้ the latest messages จะมีให้ใช้เสมอกับ the application.
•    ถ้า the FIFO lock function ถูกเปิดการใช้งาน (RFLM bit in the CAN_MCR register set) the most recent message จะ
      ถูกละทิ้งและ the software จะมี the three oldest messages ใน the FIFO ให้ใช้งาน
Title: Re: STM32F1 CAN
Post by: tha on February 02, 2021, 05:14:54 PM
Reception related interrupts

เมื่อ a message ถูกเก็บใน the FIFO แล้ว, the FMP[1:0] bits ถูกอัปเดตและ an interrupt request ถูกสร้างขึ้นถ้า the FMPIE bit in the CAN_IER register ถูกเซ็ต.

เมื่อ the FIFO มาเป็นเต็ม (อย่างเช่น a third message ถูกเก็บ) the FULL bit ใน the CAN_RFR register ถูกเซ็ตและ an interrupt ถูกสร้างขึ้นถ้า the FFIE bit in the CAN_IER register ถูกเซ็ต.

On overrun condition, the FOVR bit ถูกเซ็ตและ an interrupt ถูกสร้างขึ้นถ้า the FOVIE bit in the CAN_IER register ถูกเซ็ต.
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 07:43:59 AM
24.7.4 Identifier filtering

ใน the CAN protocol the identifier ของ a message ไม่เกี่ยวข้องกับ the address of a node แต่เกี่ยวข้องกับ the content of the message. ด้วยเหตุนี้ a transmitter จึงออกอากาศ message ของมันไปยัง receivers ทั้งหมด. บน message reception a receiver node ตัดสิน - ขึ้นอยู่กับ the identifier value - ว่า the software ต้องการ the message หรือไม่. ถ้า the message ถูกต้องการ, มันจะถูกคัดลอกลงใน the SRAM. ถ้าไม่, the message ต้องถูกละทิ้งโดยไม่มีการแทรกแซงโดย the software.

เพื่อเติมเต็มความต้องการนี้, the bxCAN Controller จัดให้มี 28 configurable and scalable filter banks (27-0) แก่ the application. ใน devices อื่นๆ the bxCAN Controller จัดให้มี 14 configurable and scalable filter banks (13-0) แก่ the application เพื่อรับเฉพาะ the messages ที่ the software ต้องการ. hardware filtering นี้ประหยัด CPU resources ซึ่งมิฉะนั้นจะต้องถูกต้องการเพื่อดำเนินการ filtering โดย software. แต่ละ filter bank x ประกอบด้วย two 32-bit registers, CAN_FxR0 and CAN_FxR1.
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 08:51:20 AM
Scalable width

เพื่อทำให้เหมาะที่สุดและปรับ the filters ตาม the application ต้องการ, แต่ละ filter bank สามารถถูกปรับขนาดอย่างเป็นอิสระ. ขึ้นอยูกับ the filter scale  ที่ a filter bank จัดให้มี :
• One 32-bit filter for the STDID[10:0], EXTID[17:0], IDE and RTR bits.
• Two 16-bit filters for the STDID[10:0], RTR, IDE and EXTID[17:15] bits.

อ้างอิงถึง  Figure 230.

นอกจากนี้, the filters สามารถถูกกำหนดค่าใน mask mode หรือใน identifier list mode.

Mask mode

ใน mask mode the identifier registers ที่เกี่ยวข้องกับ mask registers ระบุซึ่ง bits ของ the identifier ถูกรับมือเป็น "ต้องตรงกัน" หรือเป็น "ไม่สนใจ".

Identifier list mode

ใน identifier list mode, the mask registers ถูกใช้เป็น identifier registers. ดังนั้นแทนที่จะกำหนด an identifier and a mask, two identifiers ถูกระบุ, สองเท่า the number of single identifiers. ทุกบิตของ the incoming identifier ต้องตรงกับ the bits ที่ระบุใน the filter registers
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 09:54:52 AM
Filter bank scale and mode configuration

The filter banks ถูกกำหนดค่าโดยหนทางของ the corresponding CAN_FMR register. เพื่อกำหนดค่า a filter bank มันต้องถูกปิดการใช้งานโดยการเคลียร์ the FACT bit ใน the CAN_FAR register. The filter scale ถูกกำหนดค่าโดยหนทางของ the corresponding FSCx bit in the CAN_FS1R register, อ้างอิงถึง Figure 230. The identifier list หรือ identifier mask mode สำหรับ the corresponding Mask/Identifier registers ถูกกำหนดค่าโดยหนทางของ the FBMx bits ใน the CAN_FMR register.

เพื่อกรองกลุ่มของ identifiers, กำหนดค่า the Mask/Identifier registers ใน mask mode.

เพื่อเลือก single identifiers, กำหนดค่า the Mask/Identifier registers ใน identifier list mode

Filters ไม่ถูกใช้โดย the application ควรถูกปิดการใช้งาน

แต่ละ filter ภายใน a filter bank จะมีหมายเลขกำกับ (เรียกว่า the Filter Number) จาก 0 ถึง a maximum ขึ้นอยู่กับ the mode และ the scale ของแต่ละของ the filter banks.

เกี่ยวกับ the filter configuration, อ้างอิงถึง Figure 230.

(https://i.imgur.com/qqPdCqI.png)
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 11:00:53 AM
Filter match index

เมื่อ a message ถูกรับแล้วใน the FIFO มันมีให้ใช้ประโยชน์แก่ the application.  โดยปกติแล้ว, application data ถูกคัดลอกลงใน SRAM locations. เพื่อคัดลอก the data ไปยังตำแหน่งที่ถูกต้อง the application ต้องวินิจฉัย the data โดยหนทางของ the identifier. เพื่อหลีกเลี่ยงการนี้และเพื่อให้ง่ายต่อการเข้าถึง the SRAM locations, the CAN controller จัดให้มี a Filter Match Index.

ดัชนีนี้ถูกเก็บใน the mailbox พร้อมกันกับ the message สอดคล้องกับo the filter priority rules. ดังนั้นแต่ละ received message จะมี associated filter match index ของมัน.

The Filter Match index สามารถถูกใช้ในสองวิธี:
•    เปรียบเทียบ the Filter Match index กัย a list of expected values.
•    ใช้ the Filter Match Index เป็น an index บน an array เพื่อเข้าถึง the data destination location.

สำหรับ nonmasked filters, the software ไม่ต้องเปรียบเทียบ the identifier.

ถ้า the filter ถูกบัง the software จะลดการเปรียบเทียบเฉพาะกับ the masked bits เท่านั้น.

The index value ของ the filter number ไม่ได้คำนึงถึง the activation state of the filter banks. นอกจากนี้, two independent numbering schemes ถูกใช้, หนึ่งสำหรับแต่ละ FIFO. อ้างอิงถึง Figure 231 สำหรับตัวอย่าง.

(https://i.imgur.com/RitTqFC.png)
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 03:20:30 PM
Filter priority rules

ขึ้นอยู่กับ the filter combination มันอาจเกิดขึ้นที่ an identifier ผ่านได้สำเร็จผ่านทางหลายๆ filters. ในกรณีนี้ the filter match value ที่เก็บใน the receive mailbox ถูกเลือกสอดคล้องกับกฎลำดับความสำคัญต่อไปนี้:
•    A 32-bit filter มีความสำคัญเหนือกว่า a 16-bit filter.
•    สำหรับ filters ที่มีขนาดเท่ากัน, priority จะถูกกำหนดให้กับ the Identifier List mode เหนือกว่า the Identifier Mask mode
•    สำหรับ filters ที่มีขนาดและโหมดเท่ากัน priority จะถูกกำหนดให้โดย the filter number ( the number ยิ่งต่ำ, the priority ยิ่ง
      สูง).

(https://i.imgur.com/ImpucTl.png)

ตัวอย่างข้างบนแสดง the filtering principle ของ the bxCAN. บน reception ของ a message, the identifier ถูกเปรียบเทียบก่อนด้วย the filters ที่กำหนดค่าใน identifier list mode. ถ้ามีการตรงกัน, the message จะถูกเก็บใน the associated FIFO และ the index ของ the matching filter จะถูกเก็บใน the Filter Match Index. ดังแสดงในตัวอย่าง, the identifier ตรงกับ Identifier #2 ดังนั้น the message content และ FMI 2 ถูกเก็บใน the FIFO.

ถ้าไม่ตรงกัน, the incoming identifier จากนั้นถูกเปรียบเทียบกับ the filters ที่กำหนดค่าใน mask mode.

ถ้า the identifier ไม่ตรงกันกับ the identifiers ใดๆที่กำหนดค่าใน the filters, the message จะถูกละทิ้งโดย hardware โดยไม่รบกวน the software.
Title: Re: STM32F1 CAN
Post by: tha on February 03, 2021, 03:52:02 PM
24.7.5 Message storage

The interface ระหว่าง the software และ the hardware สำหรับ the CAN messages ถูกทำให้สำเร็จลงโดยหนทางของ mailboxes. A mailbox บรรจุข้อมูลทั้งหมดที่เกี่ยวข้องกับ a message; identifier, data, control, status and time stamp information.

Transmit mailbox

The software ตั้งค่า the message ที่จะถูกส่งใน an empty transmit mailbox. The status ของ the transmission ถูกแสดงให้เห็นโดย hardware ใน the CAN_TSR register.

(https://i.imgur.com/GNDX5xr.png)

Receive mailbox

เมื่อ a message ถูกรับแล้ว, มันมีให้ใช้ประโยชน์แก่ the software ใน the FIFO output mailbox. เมื่อ the software จัดการกับ the message แล้ว (ตัวอย่างเช่น อ่านมัน) the software ต้องปลดปล่อย the FIFO output mailbox โดยหนทางของ the RFOM bit ใน the CAN_RFR register เพื่อทำให้ the next incoming message มีให้ใช้ประโยชน์ได้. The filter match index ถูกเก็บใน the
MFMI field ของ the CAN_RDTxR register. The 16-bit time stamp value ถูกเก็บใน the TIME[15:0] field ของ CAN_RDTxR.

(https://i.imgur.com/7waE0Qw.png)
Title: Re: STM32F1 CAN
Post by: tha on February 04, 2021, 07:23:32 AM
(https://i.imgur.com/B9DlGpB.png)

24.7.6 Error management

The error management ดังอธิบายใน the CAN protocol ถูกจัดการทั้งหมดโดย hardware โดยใช้ a Transmit Error Counter (TEC value, in CAN_ESR register) และ a Receive Error Counter (REC value, in the CAN_ESR register), ซึ่งจะเพิ่มขึ้นหรือลดลงสอดคล้องกับ the error condition. สำหรับข้อมูลที่ละเอียดเกี่ยวกับ TEC and REC management, อ้างอิงถึง the CAN
standard.

ทั้งสองอย่างนี้อาจถูกอ่านโดย software เพื่อตรวจสอบความเสถียรของ the network. นอกจากนี้, the CAN hardware จัดให้มีข้อมูลโดยละเอียดบน the current error status ใน CAN_ESR register. โดยหนทางของ the CAN_IER register (ERRIE bit, ฯลฯ.), the software สามารถกำหนดค่า the interrupt generation บน error detection ในวิธีที่ยืดหยุ่นมาก.

Bus-Off recovery

The Bus-Off state ถูกถึงเมื่อ TEC มากกว่า 255, state นี้ถูกแสดงให้เห็นโดย BOFF bit in CAN_ESR register. ใน Bus-Off state, the bxCAN ไม่สามารถจะ transmit and receive messages ได้อีกต่อไป.

ขึ้นอยู่กับ the ABOM bit in the CAN_MCR register bxCAN จะกู้กลับคืนจาก Bus-Off (มาเป็น error active อีกครั้ง) อย่างใดอย่างหนึ่งโดยอัตโนมัติหรือบน software request. แต่ในทั้งสองกรณี the bxCAN ต้องคอยอย่างน้อยสำหรับ the recovery sequence ที่ระบุใน the CAN standard (128 การเกิดขึ้นของ 11 consecutive recessive bits ที่มอนิเตอร์บน CANRX).

ถ้า ABOM ถูกเซ็ต, the bxCAN จะสตาร์ท the recovering sequence โดยอัตโนมัติหลังจากมันได้เข้าสู่ Bus-Off state แล้ว.

ถ้า ABOM ถูกเคลียร์, the software ต้องเริ่มต้น the recovering sequence โดยการร้องขอ bxCAN เพื่อเข้าสู่และเพื่อออกจาก initialization mode

Note: ใน initialization mode, bxCAN ไม่มอนิเตอร์ the CANRX signal, ดังนั้นมันไม่สามารถเสร็จสมบูรณ์ the recovery
            sequence. เพื่อกู้กลับคืน, bxCAN ต้องอยู่ใน normal mode.
Title: Re: STM32F1 CAN
Post by: tha on February 04, 2021, 09:33:54 AM
24.7.7 Bit timing

The bit timing logic มอนิเตอร์ the serial bus-line และดำเนินการสุมตัวอย่างและปรับ the sample point โดย synchronizing บน the start-bit edge และ resynchronizing บนขอบที่ตามมา.

การทำงานของมันอาจถูกอธิบายง่ายๆโดยการแยก nominal bit time ลงในสามส่วนดังต่อไปนี้:
•    Synchronization segment (SYNC_SEG): การเปลี่ยนแปลงเล็กน้อยถูกคาดว่าจะเกิดขึ้นภายใน time segment นี้. มันมี a fixed
       length of one time quantum (1 x tq).
•    Bit segment 1 (BS1): กำหนดตำแหน่งของ the sample point. มันประกอบด้วย the PROP_SEG and PHASE_SEG1
       of the CAN standard. ระยะเวลาของมันสามารถโปรแกรมได้ระหว่าง 1 and 16 time quanta  แต่อาจยาวขึ้นโดยอัตโนมัติเพื่อ
       ชดเชยสำหรับ positive phase drifts เนื่องจากความแตกต่างใน the frequency ของ the various nodes ของ the network.
•    Bit segment 2 (BS2): กำหนดตำแหน่งของ the transmit point. มันแทน the PHASE_SEG2 of the CAN
       standard. ระยะเวลาของมันสามารถโปรแกรมได้ระหว่าง 1 and 8 time quanta แต่อาจสั้นลงโดยอัตโนมัติได้อีกด้วยเพื่อชดเชย
       สำหรับ negative phase drifts.
Title: Re: STM32F1 CAN
Post by: tha on February 04, 2021, 10:37:44 AM
The resynchronization Jump Width (SJW) กำหนดขอบเขตบนเป็นจำนวนของการยาวขึ้นหรือสั้นลงของ the bit segments. มันสามารถโปรแกรมได้ระหว่าง 1 and 4 time quanta

A valid edge ถูกกำหนดเป็น the first transition ใน a bit time จาก dominant ไปยัง recessive bus level จัดให้มี the controller ของตัวมันเองที่จะไม่ส่ง a recessive bit.

ถ้า a valid edge ถูกตรวจพบใน BS1 แทนที่จะเป็น SYNC_SEG, BS1 ถูกยืดโดยขึ้นกับ SJW ดังนั้น the sample point ถูกหน่วงเวลา.

ในทางกลับกัน, ถ้า a valid edge ถูกตรวจพบใน BS2 แทนที่จะเป็น SYNC_SEG, BS2 ถูกทำให้สั้นลงโดยขึ้นกับ SJW ดังนั้น the transmit point ถูกย้ายมาก่อนหน้าขึ้น.

ดังที่มีการป้องกันต้าน programming errors, the configuration of the Bit Timing Register (CAN_BTR) สามารถทำได้เฉพาะในขณะที่ the device อยู่ใน Standby mode.

Note: สำหรับการอธิบายอย่างละเอียดของ the CAN bit timing and resynchronization mechanism, อ้างอิงถึง the ISO 11898
           standard

(https://i.imgur.com/5QfB4D2.png)

(https://i.imgur.com/CMQBAr7.png)

Error flag: 6 dominant bits if node is error active else 6 recessive bits.
Error flag: 6 dominant bits ถ้า node คือ error active ถ้าเป็นอย่างอื่น 6 recessive bits.

Suspend transmission: applies to error passive nodes only.
Suspend transmission: ใช้กับ error passive nodes เท่านั้น.
Title: Re: STM32F1 CAN
Post by: tha on February 04, 2021, 02:05:41 PM
24.8 bxCAN interrupts

Four interrupt vectors ถูกอุทิศให้ bxCAN. แต่ละ interrupt source สามารถถูก enabled or disabled อย่างอิสระโดยหนทางของ the CAN Interrupt Enable Register (CAN_IER).

(https://i.imgur.com/yzx8yB0.png)

•    The transmit interrupt สามารถถูกสร้างขึ้นโดยเหตุการณ์ต่อไปนี้:
      –    Transmit mailbox 0 มาเป็น empty, RQCP0 bit in the CAN_TSR register set.
      –    Transmit mailbox 1 มาเป็น empty, RQCP1 bit in the CAN_TSR register set.
      –    Transmit mailbox 2 มาเป็น empty, RQCP2 bit in the CAN_TSR register set.

•    The FIFO 0 interrupt สามารถถูกสร้างขึ้นโดยเหตุการณ์ต่อไปนี้:
      –    Reception of a new message, FMP0 bits in the CAN_RF0R register are not '00'.
      –    FIFO0 full condition, FULL0 bit in the CAN_RF0R register set.
      –    FIFO0 overrun condition, FOVR0 bit in the CAN_RF0R register set.

•    The FIFO 1 interrupt สามารถถูกสร้างขึ้นโดยเหตุการณ์ต่อไปนี้:
      –    Reception of a new message, FMP1 bits in the CAN_RF1R register are not '00'.
      –    FIFO1 full condition, FULL1 bit in the CAN_RF1R register set.
      –    FIFO1 overrun condition, FOVR1 bit in the CAN_RF1R register set.

•    The error and status change interrupt สามารถถูกสร้างขึ้นโดยเหตุการณ์ต่อไปนี้:
      –    Error condition, สำหรับรายละเอียดที่มากขึ้นบน error conditions อ้างอิงถึง the CAN Error Status register
            (CAN_ESR).
      –    Wakeup condition, SOF ถูกมอนิเตอร์บน the CAN Rx signal.
      –    เข้าสู่ Sleep mode.
Title: Re: STM32F1 CAN
Post by: tha on February 05, 2021, 07:54:02 AM
24.9 CAN registers

The peripheral registers ต้องถูกเข้าถึงโดย words (32 bits).

24.9.1 Register access protection

ความผิดพลาดเข้าถึงไปยัง certain configuration registers สามารถเป็นเหตุให้ the hardware รบกวนชั่วคราวต่อ the whole CAN network. ดังนั้น the CAN_BTR register สามารถถูกแก้ไขโดย software เฉพาะขณะที่ the CAN hardware อยู่ใน initialization mode.

แม้ว่า the transmission ของ incorrect data จะไม่เป็นเหตุให้เกิดปัญหาที่ the CAN network level, มันสามารถรบกวนอย่างรุนแรงกับ the application. A transmit mailbox สามารถถูกแก้ไขโดย software เฉพาะขณะที่มันอยู่ใน empty state, อ้างอิงถึง Figure 228.

The filter values สามารถถูกแก้ไขอย่างใดอย่างหนึ่งปิดการใช้งาน the associated filter banks หรือโดยการเซ็ต the FINIT bit. ยิ่งไปกว่านั้น, the modification of the filter configuration (scale, mode and FIFO assignment) in CAN_FMxR, CAN_FSxR and CAN_FFAR registers สามารถถูกทำเมื่อ the filter initialization mode ถูกเซ็ต (FINIT=1) in the CAN_FMR register.
Title: Re: STM32F1 CAN
Post by: tha on February 05, 2021, 09:57:43 AM
(https://i.imgur.com/Ik0dx5i.png)

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

Bit 16 DBF: Debug freeze
     0: CAN ทำงานในระหว่าง debug
     1: CAN reception/transmission ถูกแช่แข็งในระหว่าง debug. Reception FIFOs สามารถยังคงถูกเข้าถึง/ควบคุมเป็นปกติ

Bit 15 RESET: bxCAN software master reset
     0: ทำงานตามปกติ.
     1: บังคับให้ a master รีเซ็ต the bxCAN -> Sleep mode ถูกทำให้ทำงานหลังจากรีเซ็ต (FMP bits และ CAN_MCR register
         ถูกเริ่มต้นเป็น the reset values). บิตนี้ถูกรีเซ็ตเป็น 0 โดยอัตโนมัติ.

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

Bit 7 TTCM: Time triggered communication mode
     0: Time Triggered Communication mode ถูกปิดการใช้งาน
     1: Time Triggered Communication mode ถูกเปิดการใช้งาน
Note: สำหรับข้อมูลที่มากขึ้นบน Time Triggered Communication mode อ้างอิงถึง Section 24.7.2.

Bit 6 ABOM: Automatic bus-off management
บิตนี้ควบคุมพฤติกรรมของ the CAN hardware บนการออกจากไป the Bus-Off state.
     0: The Bus-Off state ถูกออกจากไปบน software request, เมื่อ 128 การเกิดขึ้นของ 11 recessive bits ได้ถูกมอนิเตอร์แล้ว
         และ the software เซ็ตเป็นอันดับแรกและเคลียร์ the INRQ bit ของ the CAN_MCR register.
     1: The Bus-Off state ถูกออกจากไปโดยอัตโนมัติโดย hardware เมื่อ 128 การเกิดขึ้นของ 11 recessive bits ได้ถูกมอนิเตอร์แล้ว
สำหรับรายละเอียดข้อมูลบน the Bus-Off state อ้างอิงถึง Section 24.7.6.

Bit 5 AWUM: Automatic wakeup mode
บิตนี้ควบคุมพฤติกรรมของ the CAN hardware บน message reception ในระหว่าง Sleep mode.
     0: The Sleep mode ถูกออกจากไปบน software request โดยการเคลียร์ the SLEEP bit of the CAN_MCR register.
     1: The Sleep mode ถูกออกจากไปโดยอัตโนมัติโดย hardware บน CAN message detection. The SLEEP bit of the
         CAN_MCR register and the SLAK bit of the CAN_MSR register ถูกเคลียร์โดย hardware.
Title: Re: STM32F1 CAN
Post by: tha on February 05, 2021, 11:00:31 AM
Bit 4 NART: No automatic retransmission
     0: The CAN hardware จะส่งซ้ำ the message โดยอัตโนมัติจนกระทั่งมันถูกส่งสำเร็จลงสอดคล้องกับ the CAN standard.
     1: A message จะถูกส่งเพียงครั้งเดียว, เป็นอิสระจาก the transmission result (successful, error or arbitration lost).

Bit 3 RFLM: Receive FIFO locked mode
     0: Receive FIFO ไม่ถูกล็อคบน overrun. เมื่อ a receive FIFO เต็มแล้ว the next incoming message จะเขียนทับข้อความก่อน
         หน้า.
     1: Receive FIFO ถูกล็อคต้าน overrun. เมื่อ a receive FIFO เต็มแล้ว the next incoming message จะถูกละทิ้ง

Bit 2 TXFP: Transmit FIFO priority
บิตนี้ควบคุม the transmission order เมื่อหลาย mailboxes ได้ค้างไว้ในเวลาเดียวกัน
     0: Priority ถูกขับโดย the identifier of the message
     1: Priority ถูกขับโดย the request order (ตามลำดับเวลา)

Bit 1 SLEEP: Sleep mode request
บิตนี้ถูกเซ็ตโดย software เพื่อร้องขอ the CAN hardware ให้เข้าสู่ the Sleep mode. Sleep mode จะถูกเข้าสู่ทันทีที่ the current CAN activity (transmission or reception of a CAN frame) ได้เสร็จสมบูรณ์แล้ว.
บิตนี้ถูกเคลียร์โดย software เพื่อออกจาก Sleep mode.
บิตนี้ถูกเคลียร์โดย hardware เมื่อ the AWUM bit ถูกเซ็ตและ a SOF bit ถูกตรวจพบบน the CAN Rx signal.
บิตนี้ถูกเซ็ตหลังจากรีเซ็ต - CAN สตาร์ทใน Sleep mode.

Bit 0 INRQ: Initialization request
The software เคลียร์บิตนี้เพื่อสวิทช์ the hardware ลงใน normal mode. เมื่อ 11 consecutive recessive bits ได้ถูกมอนิเตอร์แล้วบน the Rx signal the CAN hardware ถูก synchronized และพร้อมสำหรับr transmission and reception. Hardware ให้สัญญาณเหตุการณ์นี้โดยการเคลียร์ the INAK bit ใน the CAN_MSR register.

Software เซ็ตบิตนี้เพื่อร้องขอ the CAN hardware ให้เข้าสู่ initialization mode. เมื่อ software ได้เซ็ต the INRQ bit แล้ว, the CAN hardware คอยจนกระทั่ง the current CAN activity (transmission or reception) เสร็จสมบูรณ์ก่อนการเข้าสู่ the initialization mode. Hardware ให้สัญญาณเหตุการณ์นี้โดยการเซ็ต the INAK bit in the CAN_MSR register.
Title: Re: STM32F1 CAN
Post by: tha on February 06, 2021, 07:16:47 AM
(https://i.imgur.com/2KFyvkl.png)

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

Bit 11 RX: CAN Rx signal
มอนิเตอร์ค่าจริงของ the CAN_RX Pin.

Bit 10 SAMP: Last sample point
ค่าของ RX บน the last sample point (current received bit value).

Bit 9 RXM: Receive mode
The CAN hardware เป็น currently receiver.

Bit 8 TXM: Transmit mode
The CAN hardware เป็น currently transmitter.

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

Bit 4 SLAKI: Sleep acknowledge interrupt
เมื่อ SLKIE=1, บิตนี้ถูกเซ็ตโดย hardware เพื่อให้สัญญาณว่า the bxCAN ได้เข้าสู่ Sleep Mode แล้ว. เมื่อเซ็ต, บิตนี้สร้าง a status change interrupt ถ้า the SLKIE bit ใน the CAN_IER register ถูกเซ็ต.
บิตนี้เคลียร์โดย software หรือโดย hardware, เมื่อ SLAK ถูกเคลียร์.
Note: When SLKIE=0, ไม่มีการวนสำรวจบน SLAKI สามารถเป็นไปได้. ในกรณีนี้ the SLAK bit สามารถถูกวนสำรวจ.

Bit 3 WKUI: Wakeup interrupt
บิตนี้ถูกเซ็ตโดย hardware เพื่อให้สัญญาณว่า a SOF bit ถูกตรวจพบแล้วในขณะที่ the CAN hardware เคยอยู่ใน Sleep mode. การเซ็ตบิตนี้จะสร้าง a status change interrupt ถ้า the WKUIE bit ใน the CAN_IER register ถูกเซ็ต.
บิตนี้ถูกเคลียร์โดย software
Title: Re: STM32F1 CAN
Post by: tha on February 06, 2021, 08:41:38 AM
Bit 2 ERRI: Error interrupt
บิตนี้ถูกเซ็ตโดย hardware เมื่อ a bit of the CAN_ESR ถูกเซ็ตแล้วบน error detection และ the corresponding interrupt ใน the CAN_IER ถูกเปิดการใช้งาน. การเซ็ตบิตนี้สร้าง a status change interrupt ถ้า the ERRIE bit ใน the CAN_IER register ถูกเซ็ต.
บิตนี้ถูกเคลียร์โดย software

Bit 1 SLAK: Sleep acknowledge
บิตนี้ถูกเซ็ตโดย hardware และแสดงให้เห็นไปยัง the software ว่า the CAN hardware ปัจจุบันอยู่ใน Sleep mode. บิตนี้รับทราบ the Sleep mode ที่ร้องขอจาก the software (เซ็ต SLEEP bit in CAN_MCR register).
บิตนี้ถูกเคลียร์โดย hardware เมื่อ the CAN hardware ออกจาก Sleep mode แล้ว (ถูก synchronized บน the CAN bus). เพื่อจะถูก synchronized the hardware ต้องมอนิเตอร์ a sequence of 11 consecutive recessive bits บน the CAN RX signal.
Note: ขั้นตอนของการออกจาก Sleep mode ถูกทริกเมื่อ the SLEEP bit ใน the CAN_MCR register ถูกเคลียร์. อ้างอิงถึง the
            AWUM bit ของ the CAN_MCR register description สำหรับรายละเอียดข้อมูลสำหรับการเคลียร์ SLEEP bit

Bit 0 INAK: Initialization acknowledge
บิตนี้ถูกเซ็ตโดย hardware และแสดงให้เห็นไปยัง the software ว่า the CAN hardware ปัจจุบันอยู่ใน initialization mode. บิตนี้รับทราบ the initialization ที่ร้องขอจาก the software (เซ็ต INRQ bit in CAN_MCR register).
บิตนี้ถูกเคลียร์โดย hardware เมื่อ the CAN hardware ออกจาก the initialization mode แล้ว (ถูก synchronized on the CAN bus). เพื่อจะถูก synchronized the hardware ต้องมอนิเตอร์ a sequence of 11 consecutive recessive bits on the CAN RX signal.
Title: Re: STM32F1 CAN
Post by: tha on February 07, 2021, 06:58:31 AM
(https://i.imgur.com/YKNkQEA.png)

Bit 31 LOW2: Lowest priority flag for mailbox 2
บิตนี้ถูกเซ็ตโดย hardware เมื่อมากกว่าหนึ่ง mailbox กำลังค้างอยู่สำหรับ transmission และ mailbox 2 มี the lowest priority.

Bit 30 LOW1: Lowest priority flag for mailbox 1
บิตนี้ถูกเซ็ตโดย hardware เมื่อมากกว่าหนึ่ง mailbox กำลังค้างอยู่สำหรับ transmission และ mailbox 1 มี the lowest priority.

Bit 29 LOW0: Lowest priority flag for mailbox 0
บิตนี้ถูกเซ็ตโดย hardware เมื่อมากกว่าหนึ่ง mailbox กำลังค้างอยู่สำหรับ transmission และ mailbox 0 มี the lowest priority.
Note: The LOW[2:0] bits ถูกเซ็ตเป็นศูฯย์เมื่อมีเพียงหนึ่ง mailbox กำลังค้างอยู่.

Bit 28 TME2: Transmit mailbox 2 empty
บิตนี้ถูกเซ็ตโดย hardware เมื่อไม่มี transmit request กำลังค้างอยู่สำหรับ mailbox 2.

Bit 27 TME1: Transmit mailbox 1 empty
บิตนี้ถูกเซ็ตโดย hardware เมื่อไม่มี transmit request กำลังค้างอยู่สำหรับ mailbox 1.

Bit 26 TME0: Transmit mailbox 0 empty
บิตนี้ถูกเซ็ตโดย hardware เมื่อไม่มี transmit request กำลังค้างอยู่สำหรับ mailbox 0.

Bits 25:24 CODE[1:0]: Mailbox code
ในกรณีอย่างน้อยหนึ่ง transmit mailbox ถูกปล่อยเป็นอิสระ, the code value จะเท่ากับจำนวนของ the next transmit mailbox ที่เป็นอิสระ.
ในกรณีทุก transmit mailboxes กำลังค้างอยู่, the code value จะเท่ากับจำนวนของ the transmit mailbox ที่มี the lowest priority.
Title: Re: STM32F1 CAN
Post by: tha on February 07, 2021, 08:09:28 AM
Bit 23 ABRQ2: Abort request for mailbox 2
เซ็ตโดย software เพื่อยกเลิก the transmission request สำหรับ the corresponding mailbox.
เคลียร์โดย hardware เมื่อ the mailbox มาเป็น empty.
การเซ็ตบิตนี้ไม่มีผลอะไรเมื่อ the mailbox ไม่ได้กำลังค้างอยู่สำหรับ transmission.

Bits 22:20 Reserved, must be kept at reset value.

Bit 19 TERR2: Transmission error of mailbox 2
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an error.

Bit 18 ALST2: Arbitration lost for mailbox 2
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an arbitration lost.

Bit 17 TXOK2: Transmission OK of mailbox 2
The hardware อัปเดตบิตนี้หลังจากแต่ละ transmission attempt.
     0: The previous transmission ล้มเหลว
     1: The previous transmission สำเร็จลง
บิตนี้ถูกเซ็ตโดย hardware เมื่อ the transmission request บน mailbox 2 เสร็จสำเร็จแล้ว. อ้างอิงถึง Figure 228.

Bit 16 RQCP2: Request completed mailbox2
เซ็ตโดย hardware เมื่อ the last request (transmit หรือ abort) ถูกดำเนินการแล้ว.
เคลียร์โดย software โดยการเขียน a "1" หรือโดย hardware บน transmission request (TXRQ2 เซ็ตใน CAN_TMID2R register).
การเคลียร์บิตนี้จะเคลียร์ทุก the status bits (TXOK2, ALST2 and TERR2) สำหรับ Mailbox 2.

Bit 15 ABRQ1: Abort request for mailbox 1
เซ็ตโดย software เพื่อยกเลิก the transmission request สำหรับ the corresponding mailbox.
เคลียร์โดย hardware เมื่อ the mailbox มาเป็น empty.
การเซ็ตบิตนี้ไม่มีผลอะไรเมื่อ the mailbox ไม่ได้กำลังค้างอยู่สำหรับ transmission.

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

Bit 11 TERR1: Transmission error of mailbox1
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an error.

Bit 10 ALST1: Arbitration lost for mailbox1
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an arbitration lost.
Title: Re: STM32F1 CAN
Post by: tha on February 07, 2021, 10:02:38 AM
Bit 9 TXOK1: Transmission OK of mailbox1
The hardware อัปเดตบิตนี้หลังจากแต่ละ transmission attempt.
     0: The previous transmission ล้มเหลว
     1: The previous transmission สำเร็จลง
บิตนี้ถูกเซ็ตโดย hardware เมื่อ the transmission request บน mailbox 1 เสร็จสำเร็จแล้ว. อ้างอิงถึง Figure 228.

Bit 8 RQCP1: Request completed mailbox1
เซ็ตโดย hardware เมื่อ the last request (transmit หรือ abort) ถูกดำเนินการแล้ว.
เคลียร์โดย software โดยการเขียน a "1" หรือโดย hardware บน transmission request (TXRQ1 เซ็ตใน CAN_TMI1R register).
การเคลียร์บิตนี้จะเคลียร์ทุก the status bits (TXOK1, ALST1 and TERR1) สำหรับ Mailbox 1.

Bit 7 ABRQ0: Abort request for mailbox0
เซ็ตโดย software เพื่อยกเลิก the transmission request สำหรับ the corresponding mailbox.
เคลียร์โดย hardware เมื่อ the mailbox มาเป็น empty.
การเซ็ตบิตนี้ไม่มีผลอะไรเมื่อ the mailbox ไม่ได้กำลังค้างอยู่สำหรับ transmission.

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

Bit 3 TERR0: Transmission error of mailbox0
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an error.

Bit 2 ALST0: Arbitration lost for mailbox0
บิตนี้ถูกเซ็ตเมื่อ the previous TX ล้มเหลวเนื่องจาก an arbitration lost.

Bit 1 TXOK0: Transmission OK of mailbox0
The hardware อัปเดตบิตนี้หลังจากแต่ละ transmission attempt.
     0: The previous transmission ล้มเหลว
     1: The previous transmission สำเร็จลง
บิตนี้ถูกเซ็ตโดย hardware เมื่อ the transmission request บน mailbox 0 เสร็จสำเร็จแล้ว. อ้างอิงถึง Figure 228.

Bit 0 RQCP0: Request completed mailbox0
เซ็ตโดย hardware เมื่อ the last request (transmit หรือ abort) ถูกดำเนินการแล้ว.
เคลียร์โดย software โดยการเขียน a "1" หรือโดย hardware บน transmission request (TXRQ0 เซ็ตใน CAN_TMI0R register).
การเคลียร์บิตนี้จะเคลียร์ทุก the status bits (TXOK0, ALST0 and TERR0) สำหรับ Mailbox 0.
Title: Re: STM32F1 CAN
Post by: tha on February 08, 2021, 07:51:25 AM
(https://i.imgur.com/0PabOiC.png)

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.
Title: Re: STM32F1 CAN
Post by: tha on February 08, 2021, 08:37:44 AM
(https://i.imgur.com/pZk1KCJ.png)

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.
Title: Re: STM32F1 CAN
Post by: tha on February 08, 2021, 02:26:50 PM
(https://i.imgur.com/q5ifYWB.png)

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.
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 07:15:26 AM
(https://i.imgur.com/miupXdt.png)

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).
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 09:38:13 AM
(https://i.imgur.com/oE1ca0V.png)

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.
(https://i.imgur.com/eQwdYUV.png)

Bit 23 Reserved, must be kept at reset value.

Bits 22:20 TS2[2:0]: Time segment 2
บิตเหล่านี้กำหนดจำนวนของ time quanta ใน Time Segment 2.
(https://i.imgur.com/2svf7hC.png)

Bits 19:16 TS1[3:0]: Time segment 1
บิตเหล่านี้กำหนดจำนวนของ time quanta ใน Time Segment 1
(https://i.imgur.com/6NVGytO.png)
สำหรับข้อมูลที่มากขึ้นบน 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.
(https://i.imgur.com/jX5wnuZ.png)
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 11:08:08 AM
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.

(https://i.imgur.com/08JxyeC.png)
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 12:12:32 PM
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.

(https://i.imgur.com/ZoX480i.png)

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.
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 02:14:22 PM
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

(https://i.imgur.com/uXrXhkO.png)

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.
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 03:06:28 PM
(https://i.imgur.com/DwN3f4g.png)

Bits 31:24 DATA3[7:0]: Data byte 3
Data byte 3 of the message.

Bits 23:16 DATA2[7:0]: Data byte 2
Data byte 2 of the message.

Bits 15:8 DATA1[7:0]: Data byte 1
Data byte 1 of the message.

Bits 7:0 DATA0[7:0]: Data byte 0
Data byte 0 of the message.

A message สามารถบรรจุจาก 0 ถึง 8 data bytes และสตาร์ทด้วย byte 0.
Title: Re: STM32F1 CAN
Post by: tha on February 09, 2021, 03:13:21 PM
(https://i.imgur.com/jT7guqH.png)

Bits 31:24 DATA7[7:0]: Data byte 7
Data byte 7 of the message.
Note: ถ้า TGT ของ message นี้และ TTCM ทำงาน, DATA7 และ DATA6 จะถูกแทนที่โดย the TIME stamp value.

Bits 23:16 DATA6[7:0]: Data byte 6
Data byte 6 of the message.

Bits 15:8 DATA5[7:0]: Data byte 5
Data byte 5 of the message.

Bits 7:0 DATA4[7:0]: Data byte 4
Data byte 4 of the message.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 07:26:36 AM
(https://i.imgur.com/6OZIxYz.png)

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 Reserved, must be kept at reset value.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 07:44:12 AM
(https://i.imgur.com/3DFO4dZ.png)

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

Bits 15:8 FMI[7:0]: Filter match index
register นี้บรรจุ the index ของ the filter ที่ the message ที่ถูกเก็บใน the mailbox ถูกส่งผ่านเข้ามา. สำหรับรายละเอียดที่มากขึ้นบน identifier filtering อ้างอิงถึง Section 24.7.4

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 บรรจุอยู่ ( 0 ถึง 8 ). มันเป็น 0 ในกรณีของการร้องขอ a remote frame.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 07:58:31 AM
(https://i.imgur.com/Abccj5G.png)

Bits 31:24 DATA3[7:0]: Data Byte 3
Data byte 3 of the message.

Bits 23:16 DATA2[7:0]: Data Byte 2
Data byte 2 of the message.

Bits 15:8 DATA1[7:0]: Data Byte 1
Data byte 1 of the message.

Bits 7:0 DATA0[7:0]: Data Byte 0
Data byte 0 of the message.
A message สามารถบรรจุจาก 0 ถึง 8 data bytes และสตาร์ทด้วย byte 0.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 08:00:37 AM
(https://i.imgur.com/kQ3atgA.png)

Bits 31:24 DATA7[7:0]: Data Byte 7
Data byte 3 of the message.

Bits 23:16 DATA6[7:0]: Data Byte 6
Data byte 2 of the message.

Bits 15:8 DATA5[7:0]: Data Byte 5
Data byte 1 of the message.

Bits 7:0 DATA4[7:0]: Data Byte 4
Data byte 0 of the message.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 10:07:16 AM
(https://i.imgur.com/Msm9F6U.png)

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

Bits 13:8 CAN2SB[5:0]: CAN2 start bank
บิตเหล่านี้ถูกเซ็ตและเคลียร์โดย software. พวกมันกำหนด the start bank สำหรับ the CAN2 interface (Slave) ในย่าน 0 ถึง 27.
Note: เมื่อ CAN2SB[5:0] = 28d, ทุก the filters ไปยัง CAN1 สามารถถูกใช้.
           เมื่อ CAN2SB[5:0] ถูกเซ็ตเป็น 0, ไม่มี filters ถูกกำหนดให้กับ CAN1.

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

Bit 0 FINIT: Filter init mode
Initialization mode for filter banks
     0: Active filters mode.
     1: Initialization mode for the filters
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 10:16:33 AM
(https://i.imgur.com/etmnfd1.png)

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

Bits 27:0 FBMx: Filter mode
Mode ของ the registers ของ Filter x.
0: Two 32-bit registers of filter bank x อยู่ใน Identifier Mask mode.
1: Two 32-bit registers of filter bank x อยู่ใน Identifier List mode.

Note: Bits 27:14 มีให้ใช้ใน connectivity line devices เท่านั้นและถูกสงวนไว้ถ้าเป็นเบอร์อื่น.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 01:27:54 PM
(https://i.imgur.com/imH3UH0.png)

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

Bits 27:0 FSCx: Filter scale configuration
บิตเหล่านี้กำหนด the scale configuration of Filters 13-0.
     0: Dual 16-bit scale configuration
     1: Single 32-bit scale configuration

Note: Bits 27:14 มีให้ใช้ใน connectivity line devices เท่านั้นและถูกสงวนไว้ถ้าเป็นเบอร์อื่น.

Note: อ้างอิงถึง Figure 230.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 01:34:40 PM
(https://i.imgur.com/s2P3nGc.png)

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

Bits 27:0 FFAx: Filter FIFO assignment for filter x
The message ส่งผ่านเข้ามาทาง filter นี้จะถูกเก็บใน the specified FIFO.
0: Filter กำหนดให้ FIFO 0
1: Filter กำหนดให้ FIFO 1

Note: Bits 27:14 มีให้ใช้ใน connectivity line devices เท่านั้นและถูกสงวนไว้ถ้าเป็นเบอร์อื่น.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 01:43:52 PM
(https://i.imgur.com/BQkCazJ.png)

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

Bits 27:0 FACTx: Filter active
The software เซ็ตบิตนี้เพื่อทำให้ Filter x ทำงาน. เพื่อแก้ไข the Filter x registers (CAN_FxR[0:7]), the FACTx bit ต้องถูกเคลียร์หรือ the FINIT bit ของ the CAN_FMR register ต้องถูกเซ็ต.
0: Filter x ไม่ทำงาน
1: Filter x ทำงาน

Note: Bits 27:14 มีให้ใช้ใน connectivity line devices เท่านั้นและถูกสงวนไว้ถ้าเป็นเบอร์อื่น.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 02:41:42 PM
Filter bank i register x (CAN_FiRx) (i=0..27, x=1, 2)

Address offsets: 0x240..0x31C
Reset value: 0xXXXX XXXX

ใน connectivity line devices จะมี 28 filter banks, i=0 .. 27, ใน devices อื่นๆจะมี 14 filter banks i = 0 ..13. แต่ละ filter bank i ถูกประกอบด้วยs two 32-bit registers, CAN_FiR[2:1].

register นี้สามารถถูกแก้ไขได้เฉพาะเมื่อ the FACTx bit of the CAN_FAxR register ถูกเคลียร์หรือเมื่อ the FINIT bit of the CAN_FMR register ถูกเซ็ต.

(https://i.imgur.com/8LQuWur.png)

Bits 31:0 FB[31:0]: Filter bits
Identifier
แต่ละบิตของ the register ระบุระดับของบิตที่ตรงกันของ the expected identifier.
     0: Dominant bit ถูกคาดหมาย
     1: Recessive bit ถูกคาดหมาย

Mask
แต่ละบิตของ the register ระบุว่า the bit ของ the associated identifier register ต้องตรงกันกับ the corresponding bit ของ the expected identifier หรือไม่.
     0: ไม่สนใจ, the bit ไม่ได้ถูกใช้สำหรับการเปรียบเทียบ
     1: ต้องตรงกัน, the bit ของ the incoming identifier ต้องมีระดับเดียวกันที่ระบุใน the corresponding identifier register of
         the filter.

Note: ขึ้นอยู่กับ the scale and mode configuration of the filter หน้าที่ของแต่ละ register สามารถแตกต่างกัน. สำหรับ the filter
           mapping, functions description and mask registers association, อ้างอิงถึง Section 24.7.4.

           A Mask/Identifier register ใน mask mode มี the same bit แม็ปปิ้งอย่างใน identifier list mode.

           สำหรับ the register mapping/addresses of the filter banks อ้างอิงถึง Table 181.
Title: Re: STM32F1 CAN
Post by: tha on February 10, 2021, 02:51:23 PM
(https://i.imgur.com/FPzSE2t.png)

(https://i.imgur.com/5w0QL1z.png)

(https://i.imgur.com/Adw8Aiz.png)

(https://i.imgur.com/XBce13F.png)