STM32F7 3 Embedded Flash memory (FLASH)

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

Previous topic - Next topic

tha

Programming errors

ในกรณีของ error, the Flash operation (programming or erasing) ถูกยกเลิกด้วยหนึ่งใน the following errors:
•   PGAERR: Alignment Programming error
     มันไม่ถูกอนุญาติให้โปรแกรม data ไปยัง the Flash memory ที่จะข้าม the 128-bit row boundary. ในกรณีเช่นนี้, the write
     operation ไม่ถูกดำเนินการและ the program alignment error flag (PGAERR) ถูกเซ็ตใน the FLASH_SR register.
•   PGEPRR: Programming parallelism error
     The write access type (byte, half-word, word or double word) ต้องตรงกันกับ the type of parallelism ที่เลือก (x8,
     x16, x32 or x64). ถ้าไม่, the write operation ไม่ถูกดำเนินการและ the program parallelism error flag (PGPERR) ถูก
     เซ็ตใน the FLASH_SR register.
•   ERSERR: Erase sequence error
     เมื่อ an erase operation ไปยัง the flash ถูกดำเนินการโดย the code ในขณะที่ the control register ไม่ถูกกำหนดค่าอย่างถูก
     ต้อง, the ERSERR error flag จะถูกเซ็ต
•   WRPERR: Write Protection Error
     WRPERR ถูกเซ็ตถ้าหนึ่งในเงื่อนไขต่อไปนี้เกิดขึ้น:
     –   พยายามโปรแกรมหรือลบใน a write protected area (WRP)
     –   พยายามโปรแกรมหรือลบ the system memory area.
     –   การเขียนใน the OTP area ซึ่งถูกล็อคแล้ว
     –   พยายามที่จะแก้ไข the option bytes เมื่อ the read protection (RDP) ถูกเซ็ตถึง Level
     –   The Flash memory ได้รับการป้องกันการอ่านและการบุกรุกถูกตรวจพบ

ถ้า an erase operation ใน Flash memory ยังเกี่ยวข้องกับ data ใน the ART accelerator ด้วย, ผู้ใช้ต้องทำให้แน่ใจว่า data เหล่านี้ถูกเขียนใหม่ก่อนที่พวกมันจะถูกเข้าถึงในระหว่าง code execution. ถ้าสิ่งนี้ไม่สามารถถูกทำอย่างปลอดภัย, ขอแนะนำให้ล้างและ/หรือปิดการทำงาน the ART accelerator โดยการเซ็ตตามลำดับ the bits ARTRST หรือ ARTEN ของ the FLASH_CR register

Note: The ART cache สามารถถูกล้างเฉพาะถ้า if the ART accelerator ถูกปิดใช้งาน (ARTEN = 0).

tha

3.3.8 Flash Interrupts

การเซ็ต the end of operation interrupt enable bit (EOPIE) ใน the FLASH_CR register เปิดใช้งาน interrupt generation เมื่อ an erase or program operation สิ้นสุดลง, นั่นคือเมื่อ the busy bit (BSY) ใน the FLASH_SR register ถูกเคลียร์ (การทำงานเสร็จสมบูรณ์, อย่างถูกต้องหรือไม่). ในกรณีนี้, the end of operation (EOP) bit ใน the FLASH_SR register ถูกเซ็ต.

ถ้า an error เกิดขึ้นในระหว่าง a program, an erase, หรือ a read operation request, หนึ่งใน the following error flags จะถูกเซ็ตใน the FLASH_SR register:
•   PGAERR, PGPERR, ERSERR (Program error flags)
•   WRPERR (Protection error flag)

ในกรณีนี้, ถ้า the error interrupt enable bit (ERRIE) ถูกเซ็ตใน the FLASH_CR register, an interrupt จะถูกสร้างและ the operation error bit (OPERR) จะถูกเซ็ตใน the FLASH_SR register.

Note: ถ้า several successive errors ถูกตรวจพบ (ตัวอย่างเช่น, ในกรณีของ DMA ส่งถ่ายไปยัง the Flash memory), the error
          flags ไม่สามารถถูกเคลียร์จนกว่า the end of the successive write requests.



tha

3.4 FLASH Option bytes

3.4.1 Option bytes description

The option bytes ถูกกำหนดค่าโดย the end user ขึ้นอยู่กับ the application requirements.
Table 8 แสดงการจัดระเบียบของไบต์เหล่านี้ภายใน the information block.

The option bytes สามารถถูกอ่านจาก the user configuration memory locations หรือจาก the Option byte registers:
•   Flash option control register (FLASH_OPTCR)
•   Flash option control register (FLASH_OPTCR1)




tha

User and read protection option bytes

Memory address: 0x1FFF 0000
ST programmed value: 0x5500AAFF



Bits 31:13 ไม่ถูกใช้.

Bits 15:8 RDP: Read Out Protection
     The read protection ช่วยให้ผู้ใช้ป้องกัน the software code ที่เก็บใน Flash memory.
     0xAA: Level0, ไม่มี Protection
     0xCC: Level2, chip protection (debug & boot ใน RAM features ถูกปิดใช้งาน)
     อื่นๆ: Level1, ป้องกันการอ่าน memories (debug features ถูกจำกัด)

Bit 7 nRST_STDBY
     0: Reset ถูกสร้างเมื่อเข้าสู่ Standby mode.
     1: ไม่มี reset ถูกสร้าง.

Bit 6 nRST_STOP
     0: Reset ถูกสร้างเมื่อเข้าสู่ Stop mode.
     1: ไม่มี reset ถูกสร้าง.

Bit 5 IWDG_SW: Independant watchdog selection
     0: Hardware independant watchdog.
     1: Software independant watchdog.

Bit 4 WWDG_SW: Window watchdog selection
     0: Hardware window watchdog.
     1: Software window watchdog.

Bits 3:2 BOR_LEV: BOR reset Level
     บิตเหล่านี้บรรจุขอบเขตระดับแหล่งจ่ายที่ทำให้ทำงาน/ปลดปล่อย the reset. พวกมันสามารถถูกเขียนเพื่อโปรแกรม a new BOR level
     value ลงใน Flash memory.
     00: BOR Level 3 (VBOR3), brownout threshold level 3
     01: BOR Level 2 (VBOR2), brownout threshold level 2
     10: BOR Level 1 (VBOR1), brownout threshold level 1
     11: BOR ปิด, POR/PDR reset threshold level ถูกใช้งาน
   Note: สำหรับรายละเอียดเต้มเกี่ยวกับ BOR characteristics, ดุที่ the "Electrical characteristics" section ของ the product
              datasheet.

Bits 1:0 ไม่ถูกใช้

tha

User and write protection option bytes

Memory address: 0x1FFF 0008
ST programmed value: 0x0000FFFF



Bits 31:16 ไม่ถูกใช้.

Bit 15 IWDG_STOP: Independent watchdog counter freeze in stop mode
     0: แช่แข็ง IWDG counter ใน stop mode.
     1: IWDG counter ทำงานใน stop mode.

Bit 14 IWDG_STDBY: Independent watchdog counter freeze in Standby mode
     1: IWDG counter ทำงานใน standby mode.

Bits 13:8 ไม่ถูกใช้

Bits 7:0 nWRPi: Non Write Protection of sector i
     0: Write protection ทำงานบน sector i.
     1: Write protection ไม่ทำงานบน sector i.

tha

Boot address option bytes when Boot pin =0

Memory address: 0x1FFF 0010
ST programmed value: 0xFF7F 0080 (ITCM-FLASH base address)



Bits 31:16 ไม่ถูกใช้.

Bits 15:0 BOOT_ADD0[15:0]: Boot memory base address when Boot pin =0
     BOOT_ADD0[15:0] ตรงกันกับ address [29:14],
     The boot base address รองรับ address range เฉพาะจาก 0x0000 0000 ถึง 0x2004 FFFF ด้วยความละเอียด 16KB.
     Example:
     BOOT_ADD0 = 0x0000: Boot from ITCM RAM (0x0000 0000)
     BOOT_ADD0 = 0x0040: Boot from system memory bootloader (0x0010 0000)
     BOOT_ADD0 = 0x0080: Boot from Flash on ITCM interface (0x0020 0000)
     BOOT_ADD0 = 0x2000: Boot from Flash on AXIM interface (0x0800 0000)
     BOOT_ADD0 = 0x8000: Boot from DTCM RAM (0x2000 0000)
     BOOT_ADD0 = 0x8004: Boot from SRAM1 (0x2001 0000)
     BOOT_ADD0 = 0x8013: Boot from SRAM2 (0x2004 C000)

tha

Boot address option bytes when Boot pin =1

Memory address: 0x1FFF 0018
ST programmed value: 0xFFBF0040 (system memory bootoader address)



Bits 31:16 Not used

Bits 15:0 BOOT_ADD1[15:0]: Boot memory base address when Boot pin =1
     BOOT_ADD1[15:0] ตรงกันกับ address [29:14],
     The boot base address รองรับ address range เฉพาะจาก 0x0000 0000 ถึง 0x2004 FFFF ด้วยความละเอียด 16KB.
     Example:
     BOOT_ADD1 = 0x0000: Boot from ITCM RAM(0x0000 0000)
     BOOT_ADD1 = 0x0040: Boot from system memory bootloader (0x0010 0000)
     BOOT_ADD1 = 0x0080: Boot from Flash on ITCM interface (0x0020 0000)
     BOOT_ADD1 = 0x2000: Boot from Flash on AXIM interface (0x0800 0000)
     BOOT_ADD1 = 0x8000: Boot from DTCM RAM (0x2000 0000)
     BOOT_ADD1 = 0x8004: Boot from SRAM1 (0x2001 0000)
     BOOT_ADD1 = 0x8013: Boot from SRAM2 (0x2004 C000)

tha

3.4.2 Option bytes programming

เพื่อรันการทำงานใดๆบน sector นี้, the option lock bit (OPTLOCK) ใน the Flash option control register (FLASH_OPTCR) ต้องถูกเคลียร์. เพื่อถูกยอมให้เคลียร์บิตนี้, ผู้ใช้ต้องดำเนินการลำดับต่อไปนี้:
1.   เขียน OPTKEY1 = 0x0819 2A3B ใน the Flash option key register (FLASH_OPTKEYR)
2.   เขียน OPTKEY2 = 0x4C5D 6E7F ใน the Flash option key register (FLASH_OPTKEYR)

The user option bytes สามารถถูกป้องกันต้าน unwanted erase/program operations โดยการเซ็ต the OPTLOCK bit โดย software.

Modifying user option bytes

เพื่อแก้ไข the user option value, ทำตามลำดับข้างล่าง:
1.   ตรวจสอบว่าไม่มี Flash memory operation กำลังดำเนินการอยู่โดยการตรวจสอบ the BSY bit ใน the FLASH_SR register
2.   เขียน the desired option value ใน the FLASH_OPTCR register.
3.   เซ็ต the option start bit (OPTSTRT) ใน the FLASH_OPTCR register
4.   รอสำหรับ the BSY bit ที่จะถูกเคลียร์

Note: The value of an option จะถูกแก้ไขโดยอัตโนมัติโดยการลบ the information block ก่อนและจากนั้นโปรแกรมทุก the option
          bytes ด้วยค่าที่บรรจุใน the FLASH_OPTCR register.

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