STM32F1 Programming Manual

Started by tha, January 16, 2021, 06:11:52 AM

Previous topic - Next topic

tha

The Cortex-M3 รวม an exclusive access monitor ไว้, ที่ติดตามความจริงที่ว่า the processor ได้ปฏิบัติ a Load-Exclusive instruction แล้ว.

The processor เอาออก exclusive access tag ของมันหาก:
•   มันปฏิบัติ a CLREX instruction
•   มันปฏิบัติ a Store-Exclusive instruction, โดยไม่คำนึงถึงว่าการเขียนสำเร็จหรือไม่.
•   An exception เกิดขึ้น. นี้เป็นวิธีที่ the processor สามารถแก้ไข semaphore conflicts ระหว่าง different threads.

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ the synchronization primitive instructions, ดู LDREX and STREX บนหน้า 70 and CLREX บนหน้า 71.

tha

2.2.8 Programming hints for the synchronization primitives

ANSI C ไม่สามารถสร้างโดยตรง the exclusive access instructions. บาง C compilers จัดให้มี intrinsic functions สำหรับ generation of these instructions:

The actual exclusive access instruction ที่สร้างขึ้นอยู่กับ the data type of the pointer ที่ผ่านไปยัง the intrinsic function. ตัวอย่างเช่น, the following C code สร้าง the require LDREXB operation:

__ldrex((volatile char *) 0xFF);

tha

2.3 Exception model

ส่วนนี้อธิบาย the exception model.

2.3.1 Exception states

แต่ละ exception อยู่ในสถานะหนึ่งของ the following states:

Inactive                        The exception ไม่ active และไม่ pending.

Pending                        The exception กำลังรอเพื่อถูกบริการโดย the processor. An interrupt request จาก a peripheral
                                      หรือจาก software สามารถเปลี่ยนสถานะของ the corresponding interrupt ไปเป็น pending.

Active                            An exception ที่กำลังถูกบริการโดย the processor แต่ยังไม่เสร็จสมบูรณ์.
                                      Note: An exception handler สามารถอินเตอร์รัพท์การปฏิบัติของ exception handler อีกตัวหนึ่ง.
                                      ในกรณีของทั้งสอง exceptions อยู่ใน the active state.


Active and pending    The exception กำลังถูกบริการโดย the processor และมี a pending exception จาก the same
                                       source.


tha

2.3.2 Exception types

The exception types คือ:

Reset                       Reset ถูกปลุกเมื่อ power up หรือ a warm reset. The exception model ถือว่า reset เป็นรูปแบบพิเศษ
                                 ของ exception. เมือ reset ถูกยืนยัน, การทำงานของ the processor จะหยุด, อาจเกิดขึ้น ณ จุดใดๆใน an
                                 instruction. เมื่อ reset ถูกถอนการยืนยัน, execution จะสตาร์ทใหม่จาก the address ที่จัดให้มีโดย the
                                 reset entry ใน the vector table. Execution จะสตาร์ทใหม่เป็น privileged execution ใน Thread
                                 mode.

tha

NMI                          A NonMaskable Interrupt (NMI) สามารถถูกให้สัญญานโดย a peripheral หรือถูกทริกโดย software. นี้
                                 เป็น the highest priority exception นอกเหนือจาก reset. มันถูกเปิดใช้งานอย่างถาวรและมี a fixed priority
                                 of -2. NMIs ไม่สามารถเป็น:
                                 •  บังหรือป้องกันไม่ให้ทำงานโดย exception อื่นใดๆ
                                 •  ใช้สิทธิ์ก่อนโดย exception ใดๆนอกเหนือจาก Reset.

tha

Hard fault                A hard fault คือ an exception ที่เกิดขึ้นเนื่องจาก an error ในระหว่าง exception processing, หรือเนื่องจาก
                                  an exception ไม่สามารถถูกจัดการโดย exception mechanism อื่นใดๆ. Hard faults มี a fixed priority
                                  of -1, หมายความว่าพวกมันมี priority สูงกว่า exception ใดๆที่มี priority ที่กำหนดค่าได้.

tha

Memory management   A memory management fault คือ an exception ที่เกิดขึ้นเนื่องจาก a memory protection related
fault                                   fault. The fixed memory protection constraints จะตัดสิน fault นี้, สำหรับทั้ง instruction และ
                                           data memory transactions.  fault นี้ถูกใช้เพื่อยกเลิก instruction ที่เข้าถึง Execute Never (XN)
                                           memory regions.

tha

Bus fault                  A bus fault คือ an exception ที่เกิดขึ้นเนื่องจาก a memory related fault สำหรับ an instruction หรือ
                                  data memory transaction. สิ่งนี้อาจเกิดจาก error ที่ตรวจพบบน a bus ใน the memory system.