STM32F1 FSMC

Started by tha, December 29, 2020, 08:15:46 AM

Previous topic - Next topic

tha

21 Flexible static memory controller (FSMC)

Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 32 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

section นี้ใช้กับ high-density and XL-density devices เท่านั้น.

21.1 FSMC main features

The FSMC block สามารถ interface กับ synchronous and asynchronous memories and 16-bit PC memory cards. จุดประสงค์หลักของมันคือ:
•    แปล the AHB transactions ลงใน the appropriate external device protocol
•    ตอบสนอง the access timing requirements ของ the external devices

external memories ทั้งหมดแชร์ the addresses, data and control signals ด้วย the controller. แต่ละ external device ถูกเข้าถึงโดยวิธีของ a unique chip select. The FSMC ดำเนินการได้เพียง one access ในแต่ละครั้งถึง an external device.

tha

The FSMC มีคุณลักษณะหลักดังต่อไปนี้:
•    Interfaces ด้วย static memory-mapped devices ได้แก่:
      –    Static random access memory (SRAM)
      –    NOR Flash memory
      –    PSRAM (4 memory banks)
•    Two banks ของ NAND Flash ด้วย ECC hardware ที่เช็คได้สูงถึง 8 Kbytes of data
•    16-bit PC Card compatible devices
•    รองรับ burst mode เข้าถึงไปยัง synchronous devices (NOR Flash and PSRAM)
•    8- or 16-bit wide databus
•    Independent chip select control สำหรับแต่ละ memory bank
•    Independent configuration สำหรับแต่ละ memory bank
•    Programmable timings เพื่อรองรับ a wide range ของ devices, โดยเฉพาะอย่างยิ่ง:
      –    Programmable wait states (สูงถึง 15)
      –    Programmable bus turnaround cycles (up to 15)
      –    Programmable output enable and write enable delays (up to 15)
      –    Independent read and write timings and protocol, เพื่อรองรับ the widest variety of memories and timings
•    Write enable และ byte lane select outputs สำหรับใช้กับ PSRAM and SRAM devices
•    การแปลของ 32-bit wide AHB transactions ไปเป็น consecutive 16-bit or 8-bit เข้าถึงไปยัง external 16-bit or 8-bit
      devices
•    A Write FIFO, ความยาว 2-word , แต่ละ word คือ 32 bits wide, stores data เท่านั้นและไม่มี the address. ดังนั้น, FIFO นี้
      เป็นเพียงบัฟเฟอร์ AHB write burst transactions. นี้ทำให้มันสามารถที่จะเขียนไปยัง slow memories และปล่อยให้ the AHB ที่
      เร็วไปทำงานอื่น. มีเพียง one burst แต่ละครั้งเท่านั้นที่ถูก buffered: ถ้า a new AHB burst หรือ single transaction เกิดขึ้นใน
      ขณะที่ an operation กำลังดำเนินการ, the FIFO จะถูกระบายออก. The FSMC จะใส่ wait states จนกระทั่ง the current
      memory access เสร็จสมบูรณ์.
•    External asynchronous wait control

The FSMC registers ที่กำหนด the external device type และ associated characteristics โดยปกติเซ็ตที่ boot time และไม่เปลี่ยนจนกระทั่ง the next reset หรือ power-up. อย่างไรก็ตาม, มันเป็นไปได้ที่จะเปลี่ยน the settings ที่เวลาใดๆก็ได้.

tha

21.2 Block diagram

The FSMC ประกอบด้วย four main blocks:
•    The AHB interface (รวมถึง the FSMC configuration registers)
•    The NOR Flash/PSRAM controller
•    The NAND Flash/PC Card controller
•    The external device interface
The block diagram ถูกแสดงใน Figure 185.



tha

21.3 AHB interface

The AHB slave interface เปิดการใช้งาน internal CPUs และ bus master peripherals อื่นๆเพื่อเข้าถึง the external static memories.

AHB transactions ถูกแปลลงใน the external device protocol. โดยเฉพาะอย่างยิ่ง, ถ้า the selected external memory เป็น 16 หรือ 8 bits wide, 32-bit wide transactions บน the AHB ถูกแยกลงใน consecutive 16- or 8-bit accesses. The Chip Select ถูกทำให้เป็น low หรือสลับระหว่าง the consecutive accesses เมื่อดำเนินการ 32-bit aligned หรือ 32-bit unaligned accesses ตามลำดับ.

The FSMC สร้าง an AHB error ในเงื่อนไขดังต่อไปนี้:
•    เมื่อ reading หรือ writing ถึง an FSMC bank ซึ่งไม่ถูก enabled
•    เมื่อ reading หรือ writing ถึง the NOR Flash bank ขณะที่ the FACCEN bit ถูก reset ใน the FSMC_BCRx register.
•    เมื่อ reading หรือ writing ถึง the PC Card banks ขณะที่ the input pin FSMC_CD (Card Presence Detection) เป็น low.

The effect ของ this AHB error ขึ้นอยู่กับ the AHB master ซึ่งมีความพยายาม the R/W access:
•    ถ้ามันเป็น the Cortex®-M3 CPU, a hard fault interrupt ถูกสร้างขึ้น
•    ถ้าเป็น a DMA, a DMA transfer error ถูกสร้างขึ้นและ the corresponding DMA channel ถูก disabled โดยอัตโนมัติ.

The AHB clock (HCLK) คือ the reference clock สำหรับ the FSMC.

tha

21.3.1 Supported memories and transactions

General transaction rules

The requested AHB transaction data size สามารถเป็น 8-, 16- or 32-bit wide ในขณะที่ the accessed external device มี a fixed data width. นี้อาจนำไปสู่ inconsistent transfers.

ดังนั้น, บาง simple transaction rules ต้องถูกปฏิบัติตาม:
•    AHB transaction size and memory data size เท่ากัน
      ไม่มีปัญหาในกรณีนี้
•    AHB transaction size ใหญ่กว่า the memory size
      ในกรณีนี้, the FSMC แยก the AHB transaction ลงใน smaller consecutive memory accesses เพื่อตอบสนองต่อ the
      external data width.
•    AHB transaction size เล็กกว่า the memory size
      Asynchronous transfers อาจสม่ำเสมอหรือไม่สม่ำเสมอขึ้นอยู่กับ the type of external device.
      –    Asynchronous เข้าถึงไปยัง devices ที่มี the byte select feature (SRAM, ROM, PSRAM).
            a) FSMC อนุญาติให้ write transactions เข้าถึง the right data ผ่านทาง byte lanes NBL[1:0] ของมัน
            b) Read transactions ถูกอนุญาติ. memory bytes ทั้งหมดถูกอ่านและส่วนที่ไร้ประโยชน์จะถูกทิ้ง. The NBL[1:0] ถูกทำให้
                เป็น low ในระหว่าง read transactions.
      –    Asynchronous เข้าถึงไปยัง devices ที่ไม่มี the byte select feature (NOR and NAND Flash 16-bit).
            สถานการณ์นี้เกิดขึ้นเมื่อ a byte access ถูกร้องขอไปยัง a 16-bit wide Flash memory. เห็นได้ชัดว่า, the device ไม่
            สามารถถูกเข้าถึงใน byte mode (เฉพาะ 16-bit words สามารถถูกอ่านจาก/เขียนถึง the Flash memory) ดังนั้น:
           a) Write transactions ไม่ถูกอนุญาติ
           b) Read transactions ถูกอนุญาติ. memory bytes ทั้งหมดถูกอ่านและส่วนที่ไร้ประโยชน์จะถูกทิ้ง. The NBL[1:0] ถูกเซ็ต
               เป็น 0 ในระหว่าง read transactions.

tha

Configuration registers

The FSMC สามารถถูกกำหนดค่าโดยใช้ a register set. ดู Section 21.5.6, สำหรับรายละเอียดการอธิบายของ the NOR Flash/PSRAM control registers. ดู Section 21.6.8, สำหรับรายละเอียดการอธิบายของ the NAND Flash/PC Card registers.

tha

21.4 External device address mapping

จากมุมมอง the FSMC , the external memory ถูกแบ่งลงใน 4 fixed-size banks of 256 Mbytes each (Refer to Figure 186):
•    Bank 1 ถูกใช้เพื่อระบุตำแหน่งสูงถึง 4 NOR Flash or PSRAM memory devices.  bank ถูกแยกลงใน 4 NOR/PSRAM
      subbanks พร้อมด้วย 4 dedicated Chip Selects, ดังต่อไปนี้:
      –    Bank 1 - NOR/PSRAM 1
      –    Bank 1 - NOR/PSRAM 2
      –    Bank 1 - NOR/PSRAM 3
      –    Bank 1 - NOR/PSRAM 4
•    Banks 2 and 3 ถูกใช้เพื่อระบุตำแหน่ง NAND Flash devices (1 device per bank)
•    Bank 4 ถูกใช้เพื่อระบุตำแหน่ง a PC Card device

สำหรับแต่ละ bank the type of memory ที่ถูกใช้ เป็นแบบผู้ใช้กำหนดใน the Configuration register



tha

21.4.1 NOR/PSRAM address mapping

HADDR[27:26] bits ถูกใช้เลือกหนึ่งของ the four memory banks ดังแสดงใน Table 100.



1. HADDR คือ internal AHB address lines ที่ถูกแปลเป็น external memory.

HADDR[25:0] บรรจุ the external memory address. เนื่องจาก HADDR คือ a byte address ในขณะที่ the memory ถูกระบุตำแหน่งใน words, the address จริงที่ปล่อยออกไปยัง the memory แตกต่างกันไปสอดคล้องกันกับ the memory data width, ดังแสดงในตารางต่อไปนี้.


1. ในกรณีของ a 16-bit external memory width, the FSMC จะใช้โดยภายใน HADDR[25:1] เพื่อสร้าง the address สำหรับ external memory FSMC_A[24:0].
อย่างไรก็ตาม the external memory width (16-bit or 8-bit), FSMC_A[0] ควรถูกต่อถึง external memory address A[0].

Wrap support for NOR Flash/PSRAM

Wrap burst mode สำหรับ synchronous memories ไม่ได้ถูกรองรับ. The memories ต้องถูกกำหนดค่าใน linear burst mode ของความยาวที่ไม่ได้กำหนด.