STM32F1 Programming Manual

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

Previous topic - Next topic

tha

Interrupt program status register

The IPSR บรรจุ the exception type number ของ the current Interrupt Service Routine (ISR). ดู the register summary ใน Table 2 บนหน้า 15 สำหรับ attributes ของมัน. The bit assignments คือ:

tha

Execution program status register

The EPSR บรรจุ the Thumb state bit, และ the execution state bits สำหรับอย่างใดอย่างหนึ่ง the:
•   If-Then (IT) instruction
•   Interruptible-Continuable Instruction (ICI) field สำหรับ an interrupted load multiple หรือ store multiple instruction.
ดู the register summary ใน Table 2 บนหน้า 15 สำหรับ the EPSR attributes. The bit assignments คือ:

พยายามอ่าน the EPSR โดยตรงผ่านทาง application software โดยใช้ the MSR instruction จะส่งคืนกลับศูนย์เสมอ. พยายามเขียน the EPSR โดยใช้ the MSR instruction ใน application software จะถูกละเลย. Fault handlers สามารถตรวจสอบ EPSR value ใน the stacked PSR เพื่อระบุ the operation ว่าอยู่ที่ fault. ดู Section 2.3.7: Exception entry and return บนหน้า 37

tha

Interruptible-continuable instructions

เมื่อ an interrupt เกิดขึ้นในระหว่าง the execution of an LDM or STM instruction, the processor:
•   หยุด the load multiple หรือ store multiple instruction operation ไว้ชั่วคราว
•   เก็บ the next register operand ใน the multiple operation ไปยัง EPSR bits[15:12].
หลังจากการบริการ the interrupt, the processor:
•   กลับคืนไปยัง the register ที่ชี้ถึงโดย bits[15:12]
•   กลับมาทำงานต่อ execution of the multiple load or store instruction.
เมื่อ the EPSR ถือ ICI execution state, bits[26:25,11:10] จะเป็นศูนย์.

If-Then block

The If-Then block บรรจุสูงถึง four instructions ต่อจาก a 16-bit IT instruction. แต่ละ instruction ใน the block มีเงื่อนไข. เงื่อนไขสำหรับ the instructions เป็นอย่างใดอย่างหนึ่งเหมือนกันทั้งหมด, หรือบางคำสั่งอาจตรงกันข้ามกับคำสั่งอื่นๆ. ดู IT บนหน้า 94 สำหรับข้อมูลเพิ่มเติม.

Exception mask registers

The exception mask registers จะปิดใช้งาน the handling of exceptions โดย the processor. ปิดใช้งาน exceptions ที่ๆพวกมันอาจส่งผลกระทบต่อ timing critical tasks.

เพื่อเข้าถึง the exception mask registers จะใช้ the MSR and MRS instructions, หรือ the CPS instruction เพื่อเปลี่ยนค่าของ PRIMASK or FAULTMASK. ดู MRS บนหน้า 100, MSR บนหน้า 101, และ CPS บนหน้า 98 สำหรับข้อมูลเพิ่มเติม.


tha

Priority mask register

The PRIMASK register ป้องกัน activation of all exceptions ด้วย configurable priority. ดู the register summary ใน Table 2 บนหน้า 15 สำหรับ attributes ของมัน. Figure 5 แสดง the bit assignments.

tha

Fault mask register

The FAULTMASK register ป้องกัน activation of all exceptions ยกเว้นสำหรับ Non-Maskable Interrupt (NMI). ดู the register summary ใน Table 2 บนหน้าe 15 สำหรับ attributes ของมัน. Figure 6 แสดง the bit assignments.

The processor จะเคลียร์ the FAULTMASK bit เป็น 0 เมื่อออกจาก exception handler ใดๆยกเว้น the NMI handler.

tha

Base priority mask register

The BASEPRI register กำหนด the minimum priority สำหรับ exception processing. เมื่อ BASEPRI ถูกเซ็ตเป็น a nonzero value, มันจะป้องกัน the activation of all exceptions ที่มีระดับความสำคัญเท่ากันหรือต่ำกว่าค่า the BASEPRI value.  ดู the register summary ใน Table 2 บนหน้า 15 สำหรับ attributes ของมัน. Figure 7 แสดง the bit assignments.

tha

CONTROL register

The CONTROL register ควบคุม the stack ที่ใช้และ the privilege level สำหรับ software execution เมื่อ the processor อยู่ใน Thread mode.  ดู the register summary ใน Table 2 บนหน้า 15 สำหรับ attributes ของมัน. Figure 8 แสดง the bit assignments.


The Handler mode ใช้ the MSP เสมอ, ดังนั้น the processor จะละเว้นการเขียนที่ชัดเจนไปยัง the active stack pointer bit of the CONTROL register เมื่ออยู่ใน Handler mode. The exception entry และ return mechanisms จะอัฟเดต the CONTROL register.

ใน an OS environment, ขอแนะนำว่า threads ที่ทำงานใน Thread mode ใช้ the process stack และ the kernel and exception handlers ใช้ the main stack.

โดยเริ่มต้น, Thread mode ใช้ the MSP. เพื่อสลับ the stack pointer ที่ใช้ใน Thread mode ไปเป็น the PSP, ใช้ the MSR instruction เพื่อเซ็ต the Active stack pointer bit เป็น 1, ดู MSR บนหน้า 101.

เมื่อเปลี่ยน the stack pointer, software ต้องใช้ an ISB instruction ทันทีหลังจาก the MSR instruction. นี้เพื่อให้แน่ใจว่า instructions หลังจาก the ISB execute จะใช้ the new stack pointer. ดู ISB บนหน้า 100

tha

2.1.4 Exceptions and interrupts

The Cortex-M3 processor รองรับ interrupts and system exceptions. The processor และ the Nested Vectored Interrupt Controller (NVIC) จัดลำดับความสำคัญและจัดการ all exceptions. An exception เปลี่ยน the normal flow ของ software control. The processor ใช้ handler mode เพื่อจัดการ all exceptions ยกเว้นสำหรับ reset. ดู Exception entry บนหน้า 37 และ Exception return บนหน้า 38 สำหรับข้อมูลเพิ่มเติม.

The NVIC registers ควบคุม interrupt handling. ดู Memory protection unit (MPU) บนหน้า 105 สำหรับข้อมูลเพิ่มเติม.