STM32F1 CAN

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

Previous topic - Next topic

tha

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.

tha



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.

tha

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.


tha



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

tha

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.

tha



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.

tha

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.

tha

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.