STM32F7 3 Embedded Flash memory (FLASH)

Started by tha, October 05, 2022, 07:22:52 AM

Previous topic - Next topic

tha

Instruction prefetch

แต่ละ flash read operation จัดให้มี 256 bits เป็นตัวแทน 8 คำสั่งของ 32 bits ถึง 16 คำสั่งของ 16 bits สอดคล้องกับ the program ที่เปิดตัว. ดังนั้น, ในกรณีของ sequential code, อย่างน้อย 8 CPU cycles ถูกต้องการในการปฏิบัติ the previous instruction line read. The prefetch บน ITCM bus จะช่วยในการอ่าน the sequential next line of instructions ใน the flash ในขณะที่ the current instruction line ถูกร้องขอโดย the CPU. The prefetch สามารถถูกเปิดใช้งานโดยการเซ็ต the PRFTEN bit ของ the FLASH_ACR register. คุณลักษณะนี้มีประโยชน์หากอย่างน้อย one Wait State ถูกต้องการในการเข้าถึง the flash. เมื่อ the code ไม่เป็นลำดับ (branch), คำสั่งอาจไม่ปรากฏทั้งใน the current instruction line ที่ใช้หรือใน the prefetched instruction line. ในกรณีนี้ (miss), the penalty ในแง่ของ number of cycles คืออย่างน้อยเท่ากับ the number of Wait States.

tha

Adaptive real-time memory accelerator (ART Accelerator™)

The proprietary Adaptive real-time (ART) memory accelerator ได้รับการปรับให้เหมาะสมสำหรับ STM32 industry-standard Arm® Cortex®-M7 ที่มี FPU processors. มันสร้างสมดุลย์ the inherent performance advantage of the Arm® Cortex®-M7 ด้วย FPU ครอบคลุม Flash memory technologies, ซึ่งปกติต้องการให้ the processor รอสำหรับ the Flash memory ที่ higher operating frequencies.

เพื่อปลดปล่อย the processor อย่างเต็มประสิทธิภาพ, the accelerator จัดให้มีใช้ a unified cache of an instruction และ branch cache ซึ่งจะเพิ่ม program execution speed จาก the 256-bit Flash memory. ตามเกณฑ์มาตรฐาน CoreMark, the performance สำเร็จลงต้องขอบคุณ the ART accelerator ที่เทียบเท่ากับ 0 wait state program execution จาก Flash memory ที่ a CPU frequency สูงถึง 216 MHz.

tha

The ART accelerator มีให้ใช้งานเฉพาะสำหรับ flash access on ITCM interface.

เพื่อจำกัด the time lost เนื่องจาก jumps, มันสามารถทำได้ที่จะกักเก็บ 64 lines of 256 bits ใน the ART accelerator. คุณลักษณะนี้สามารถถูกเปิดใช้งานได้โดยการเซ็ต the ARTEN bit of the FLASH_CR register. The ART Accelerator ถูกรวมเป็นหนึ่งเดียว, มันบรรจุ instruction เช่นเดียวกับ data literal pools. ทุกครั้งที่ข้อผิดพลาดเกิดขึ้น (data ที่ร้องขอไม่มีอยู่ใน the current data line used หรือใน the instruction cache memory), the read line ถูกคัดลอกใน the instruction cache memory of ART. ถ้า a data ที่บรรจุใน the instruction cache memory ถูกร้องขอโดย the CPU, the data ถูกจัดให้โดยปราศจากการใส่ delay. เมื่อทุก the cache memory lines ถูกเติม, the LRU (Least Recently Used) policy ถูกใช้เพื่อตัดสิน the line ที่จะแทนที่ใน the memory cache. คุณลักษณะนี้มีประโยชน์อย่างยิ่งในกรณีของ code containing loops.

Note: Data in user configuration sector ไม่สามารถแคชได้.


tha

3.3.3 Flash program and erase operations

สำหรับ Flash memory program operation (erase or program) ใดๆ, the CPU clock frequency (HCLK) ต้องอย่างน้อย 1 MHz. สิ่งที่บรรจุอยู่ภายในของ the Flash memory จะไม่ได้รับการรับประกันถ้า a device reset เกิดขึ้นในระหว่าง a Flash memory operation.

ความพยายามใดๆที่จะอ่าน the Flash memory ในขณะที่มันกำลังถูกเขียนหรือลบ, เป็นเหตให้ the bus ถูกขัดขวาง. Read operations ถูกประมวลผลอย่างถูกต้องทันทีที่ the program operation เสร็จสมบูรณ์แล้ว. นี้หมายความว่า code or data fetches ไม่สามารถถูกกระทำในขณะที่ a write/erase operation กำลังดำเนินการอยู่.

tha

3.3.4 Unlocking the Flash control register

หลังจาก reset, การเขียนจะไม่ได้รับอนุญาติใน the Flash control register (FLASH_CR) เพื่อป้องกัน the Flash memory ต่อการทำงานที่ไม่พึงประสงค์ที่อาจเกิดขึ้นได้เนื่องจาก, ตัวอย่างเช่น, electric disturbances. ลำดับต่อไปนี้ถูกใช้เพื่อปลดล็อค register นี้:
1.   เขียน KEY1 = 0x45670123 ใน the Flash key register (FLASH_KEYR)
2.   เขียน KEY2 = 0xCDEF89AB ใน the Flash key register (FLASH_KEYR)

ลำดับที่ไม่ถูกต้องใดๆจะส่งคืนกลับ a bus error และล็อค the FLASH_CR register จนกระทั่งการรีเซ็ตครั้งถัดไป.

The FLASH_CR register สามารถถูกล็อคอีกครั้งโดย software โดยการเซ็ต the LOCK bit ใน the FLASH_CR register.

Note: The FLASH_CR register ไม่สามารถเข้าถึงได้ใน write mode เมื่อ the BSY bit ใน the FLASH_SR register ถูกเซ็ต. ความ
          พยายามใดๆที่จะเขียนถึงมันด้วย the BSY bit set จะเป็นเหตให้ the AHB bus หยุดทำงานจนกระทั่ง the BSY bit จะถูกเคลียร์.

tha

3.3.5 Program/erase parallelism

The Parallelism size ถูกกำหนดค่าผ่านทาง the PSIZE field ใน the FLASH_CR register. มันแสดงถึง the number of bytes ที่จะถูกโปรแกรมแต่ละครั้งที่ a write operation เกิดขึ้นกับ the Flash memory. PSIZE ถูกจำกัดโดย the supply voltage และโดยว่า the external VPP supply ถูกใช้หรือไม่. ดังนั้นมันต้องถูกกำหนดค่าอย่างถูกต้องใน the FLASH_CR register ก่อน programming/erasing operation ใดๆ.

A Flash memory erase operation สามารถถูกดำเนินการได้เฉพาะโดย sector, bank หรือสำหรับ the whole Flash memory (mass erase). The erase time ขึ้นอยู่กับ PSIZE programmed value. สำหรับรายละเอียดที่มากขึ้นเกี่ยวกับ the erase time, ดูที่ the electrical characteristics section ของ the device datasheet

Table 6 จัดให้มี the correct PSIZE values.



Note: Any program or erase operation ที่เริ่มต้นด้วย inconsistent program parallelism/voltage range settings อาจนำไป
          สู่ผลลัพธ์ที่ไม่คาดคิด. แม้ว่า a subsequent read operation จะแสดงให้เห็นว่า the logical value เคยถูกเขียนไปยัง the
          memory อย่างมีประสิทธิภาพ, ค่านี้ไม่สามารถถูกเก็บไว้ได้.

          ในการใช้ VPP, an external high-voltage supply (between 8 and 9 V) ต้องถูกประยุกต์ใช้กับ the VPP pad. The
          external supply ต้องสามารถรักษา voltage range นี้ได้ ถึงแม้ว่า the DC consumption จะเกิน 10 mA. ขอแนะนำให้จำกัด
          การใช้ของ VPP ไว้ที่การตั้งโปรแกรมเบื้องต้นบน the factory line. The VPP supply ต้องไม่ถูกประยุกต์ใช้เป็นเวลามากกว่าหนึ่ง
          ชั่วโมง, มิฉะนั้น the Flash memory อาจเสียหาย.

tha

3.3.6 Flash erase sequences

The Flash memory erase operation สามารถถูกดำเนินการที่ sector level หรือบน the whole Flash memory (Mass Erase). Mass Erase จะไม่กระทบ the OTP sector หรือ the configuration sector.

Sector Erase

ในการลบ a sector, ทำตามขั้นตอนข้างล่าง:
1.   ตรวจสอบว่าไม่มี Flash memory operation กำลังดำเนินการอยู่โดยการตรวจสอบ the BSY bit ใน the FLASH_SR register
2.   เซ็ต the SER bit และเลือก the sector ออกจาก the 8 ใน the main memory block) ที่ต้องการลบ (SNB) ใน the
      FLASH_CR register
3.   เซ็ต the STRT bit ใน the FLASH_CR register
4.   รอสำหรับ the BSY bit ที่จะถูกเคลียร์

Mass Erase

ในการดำเนินการ Mass Erase, ลำดับต่อไปนี้ถูกแนะนำ:
1.   ตรวจสอบว่าไม่มี Flash memory operation กำลังดำเนินการอยู่โดยการตรวจสอบ the BSY bit ใน the FLASH_SR register
2.   เซ็ต the MER bit ใน the FLASH_CR register
3.   เซ็ต the STRT bit ใน the FLASH_CR register
4.   รอสำหรับ the BSY bit ที่จะถูกเคลียร์

Note:   ถ้า MERx and SER bits ทั้งคู่ถูกเซ็ตใน the FLASH_CR register, mass erase จะถูกดำเนินการ.

            ถ้าทั้ง MERx and SER bits ถูกรีเซ็ตและ the STRT bit ถูกเซ็ต, พฤติกรรมที่คาดเดาไม่ได้อาจเกิดขึ้นโดยไม่สร้าง error flag
            ใดๆ. เงื่อนไขนี้ต้องห้าม.

Note:   เมื่อเซ็ต the STRT bit ใน the FLASH_CR register และก่อนการวนตรวจ the BSY bit จะถูกเคลียร์, the software สามารถ
            ปล่อยออก a DSB instruction เพื่อรับประกันการเสร็จสมบูรณ์ของการเข้าถึงก่อนหน้าไปยัง FLASH_CR register.

tha

3.3.7 Flash programming sequences

Standard programming

The Flash memory programming sequence เป็นดังต่อไปนี้:
1.   ตรวจสอบว่าไม่มี Flash memory operation กำลังดำเนินการอยู่โดยการตรวจสอบ the BSY bit ใน the FLASH_SR register
2.   เซ็ต the PG bit ใน the FLASH_CR register
3.   ดำเนินการ the data write operation(s) ไปยัง the desired memory address (ภายใน main memory block หรือ OTP
      area):
      –   Byte access ในกรณีของ x8 parallelism
      –   Half-word access ในกรณีของ x16 parallelism
      –   Word access ในกรณีของ x32 parallelism
      –   Double word access ในกรณีของ x64 parallelism
4.   รอสำหรับ the BSY bit ที่จะถูกเคลียร์

Note: Successive write operations สามารถทำได้โดยไม่จำเป็นต้องดำเนินการลบเมื่อเปลี่ยนบิตจาก '1' เป็น '0'. การเขียน '1' ต้องการ
          a Flash memory erase operation.

          ถ้า an erase and a program operation ถูกร้องขึ้นขอพ้อมกัน, the erase operation จะถูกดำเนินการก่อน.

Note: หลังจากดำเนินการ a data write operation และก่อนการวนตรวจ the BSY bit จะถูกเคลียร์, the software สามารถปล่อยออก a
          DSB instruction เพื่อรับประกันการเสร็จสมบูรณ์ของ a previous data write operation.