STM32F1 Programming Manual

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

Previous topic - Next topic

tha

2.1.5 Data types

The processor:
•   รองรับ the following data types:
     –   32-bit words
     –   16-bit halfwords
     –   8-bit bytes
•   รองรับ 64-bit data transfer instructions.
•   จัดการ all memory accesses (data memory, instruction memory and Private Peripheral Bus (PPB)) เป็น                   
     little-endian. ดู Memory regions, types and attributes บนหน้า 25 สำหรับข้อมูลเพิ่มเติม.

tha

2.1.6 The Cortex® microcontroller software interface standard (CMSIS)

สำหรับ a Cortex-M3 microcontroller system, the Cortex Microcontroller Software Interface Standard (CMSIS) กำหนด:
•   วิธีทั่วไปในการ:
     –   เข้าถึง peripheral registers
     –   กำหนด exception vectors
•   ชื่อของ:
     –   The registers of the core peripherals
     –   The core exception vectors
•   A device-independent interface สำหรับ RTOS kernels, รวมถึง a debug channel

The CMSIS รวม address definitions และ data structures สำหรับ the core peripherals ใน the Cortex-M3 processor. มันยังรวม optional interfaces สำหรับ middleware components ประกอบด้วย a TCP/IP stack และ a Flash file system.

CMSIS ช่วยลดความยุ่งยาก software development โดยทำให้สามารถใช้งานซ้ำ template code และการรวมของ CMSIS-compliant software components จาก various middleware vendors. Software vendors สามารถขยาย the CMSIS เพื่อรวม their peripheral definitions และเข้าถึง functions สำหรับ peripherals เหล่านั้น.

เอกสารนี้ประกอบด้วย the register names ที่กำหนดโดย the CMSIS, และให้ short descriptions ของ the CMSIS functions ที่ระบุที่อยู่ the processor core และ the core peripherals.

เอกสารนี้ใช้ the register short names ที่กำหนดโดย the CMSIS. ในน้อยกรณีชื่อเหล่านี้แตกต่างจาก the architectural short names ที่อาจถูกใช้ในเอกสารอื่นๆ

ส่วนต่อไปนี้ให้ข้อมูลเพิ่มเติมเกี่ยวกับ the CMSIS:
•   Section 2.5.4: Power management programming hints on page 43
•   Intrinsic functions on page 49
•   The CMSIS mapping of the Cortex®-M3 NVIC registers on page 119
•   NVIC programming hints on page 127

tha

2.2 Memory model

ส่วนนี้อธิบาย the processor memory map(แผนผัง), ลักษณะการทำงานของ memory accesses, และ the bit-banding features. The processor มี a fixed memory map ที่จัดให้มีสูงถึง 4 GB ของ addressable memory.

ขอบเขตสำหรับ SRAM และ peripherals รวมถึง bit-band regions. Bit-banding จัดให้มี atomic operations กับ bit data, ดู Section 2.2.5: Bit-banding บนหน้า 27.

The processor สงวนพื้นที่ของช่วงที่อยู่ the Private peripheral bus (PPB) สำหรับ core peripheral registers, ดู Section 4.1: About the STM32 core peripherals บนหน้า 105.


tha

2.2.1 Memory regions, types and attributes

The memory map แบ่ง the memory map ลงใน regions. แต่ละ region มี a defined memory type, และบาง regions มี additional memory attributes. The memory type และ attributes กำหนดลักษณะการทำงานของการเข้าถึง the region.

The memory types คือ:
Normal                           The processor สามารถจัดลำดับ transactions ใหม่เพื่อประสิทธิภาพ, หรือดำเนินการ speculative
                                         reads.

Device                            The processor จะรักษา transaction order ที่เกี่ยวข้องกับ transactions อื่นไปยัง Device หรือ
                                        Strongly-ordered memory.

Strongly-ordered          The processor จะรักษา transaction order ที่เกี่ยวข้องกับ transactions อื่นทั้งหมด.

The different ordering requirements สำหรับ Device และ Strongly-ordered memory หมายความว่า the memory system สามารถบัฟเฟอร์การเขียนไปยัง Device memory, แต่ต้องไม่บัฟเฟอร์การเขียนไปยัง Strongly-ordered memory.

The additional memory attributes ประกอบด้วย:
Execute Never (XN)      วิธีที่ the processor ป้องกัน instruction accesses. ความพยายามใดๆเพื่อเฟรช an instruction จาก an
                                        XN region เป็นเหตุให้เกิด a memory management fault exception.

tha

2.2.2 Memory system ordering of memory accesses

สำหรับ memory accesses ส่วนใหญ่ที่เกิดจาก explicit memory access instructions, the memory system จะไม่รับประกันว่าลำดับที่ the accesses complete ตรงกับ the program order ของ the instructions, การจัดให้มีที่ไม่ส่งผลกระทบลักษณะการทำงานของ the instruction sequence. โดยปกติ, ถ้า correct program execution ขึ้นอยู่กับ two memory accesses เสร็จสมบูรณ์ใน program order, software ต้องใส่ a memory barrier instruction ระหว่าง the memory access instructions, ดู Section 2.2.4: Software ordering of memory accesses บนหน้า 26.

อย่างไรก็ตาม, the memory system รับประกันบางการเรียงลำดับของการเข้าถึง Device and Strongly-ordered memory. สำหรับ two memory access instructions A1 and A2, ถ้า A1 เกิดขึ้นก่อน A2 ใน program order, ลำดับของ the memory accesses ที่เกิดจาก two instructions คือ:

tha

2.2.3 Behavior of memory accesses

ลักษณะการทำงานของการเข้าถึงแต่ละ region ใน the memory map คือ:

The Code, SRAM, and external RAM regions สามารถเก็บ programs ได้. อย่างไรก็ตาม, ขอแนะนำให้ programs ใช้ the Code region เสมอ. นี้เนื่องจาก the processor มี separate buses ที่ทำให้สามารถ instruction fetches และ data accesses to เกิดขึ้นได้พร้อมกัน.

tha

2.2.4 Software ordering of memory accesses

The order of instructions ใน the program flow ไม่รับประกัน the order of the corresponding memory transactions เสมอ. นี้เนื่องจาก:
•   The processor สามารถจัดลำดับบาง memory accesses ใหม่เพื่อปรับปรุงประสิทธิภาพให้ดีขึ้น, การจัดให้มีสิ่งนี้ไม่ส่งผลกระทบ
     ลักษณะการทำงานของ the instruction sequence.
•   The processor มี multiple bus interfaces
•   Memory or devices ใน the memory map มี wait states ที่ต่างกัน
•   บาง memory accesses ถูกบัฟเฟอร์หรือ speculative.
Section 2.2.2: Memory system ordering of memory accesses on page 25 อธิบายกรณีที่ the memory system รับประกัน the order of memory accesses. มิฉะนั้น, ถ้า the order of memory accesses วิกฤต, software ต้องรวม memory barrier instructions เพื่อบังคับ ordering นั้น. The processor จัดให้มี the following memory barrier instructions:

DMB               The Data Memory Barrier (DMB) instruction ทำให้แน่ใจว่า outstanding memory transactions เสร็จ
                        สมบูรณ์ก่อน subsequent memory transactions. ดู DMB บนหน้า 99.
DSB                The Data Synchronization Barrier (DSB) instruction ทำให้แน่ใจว่า outstanding memory transactions เ
                       สร็จสมบูรณ์ก่อน subsequent instructions execute. ดู DSB บนหน้า 100.
ISB                 The Instruction Synchronization Barrier (ISB) ทำให้แน่ใจว่าผลของ all completed memory transactions
                       จะรับรู้ได้โดย subsequent instructions. ดู ISB บนหน้า 100.

tha

ใช้ memory barrier instructions ใน, ตัวอย่างเช่น:
•   Vector table. ถ้า the program เปลี่ยน an entry ใน the vector table, และจากนั้นเปิดใช้งาน the corresponding
     exception, ใช้ a DMB instruction ระหว่าง the operations. นี้ทำให้แน่ใจว่าถ้า the exception ถูกได้รับทันที่หลังจากกำลังถูก
     เปิดใช้งาน the processor จะใช้ the new exception vector.
•   Self-modifying code. ถ้า a program บรรจุ self-modifying code, ใช้ an ISB instruction ทันที่หลังจาก the code
     modification ใน the program. นี้ทำให้แน่ใจว่า subsequent instruction execution จะใช้ the updated program
•   Memory map switching. ถ้า the system บรรจุ a memory map switching mechanism, ใช้ a DSB instruction
     หลังจากการสลับ the memory map ใน the program. นี้ทำให้แน่ใจว่า subsequent instruction execution จะใช้ the
     updated memory map.
•   Dynamic exception priority change. เมื่อ an exception priority ต้องเปลี่ยนเมื่อ the exception ค้างอยู่หรือทำงาน
     อยู่, ใช้ DSB instructions หลังจากการเปลี่ยน. นี้ทำให้แน่ใจว่าการเปลี่ยนจะส่งผลบนการเสร็จสมบูรณ์ the DSB instruction.
•   Using a semaphore in multi-master system. ถ้า the system บรรจุมากกว่าหนึ่ง bus master, ตัวอย่างเช่น, ถ้า
     processor อีกตัวหนึ่งถูกปรากฎใน the system, แต่ละ processor ต้องใช้ a DMB instruction หลังจาก semaphore
     instructions ใดๆ, เพื่อให้แน่ใจว่า bus masters อื่นๆดู the memory transactions ในลำดับซึ่งพวกมันเคยถูกปฏิบัติ.

Memory เข้าถึง Strongly-ordered memory, อย่างเช่น the system control block, ไม่จำเป็นต้องใช้ DMB instructions.