STM32F1 FSMC

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

Previous topic - Next topic

tha

SRAM/NOR-Flash write timing registers 1..4 (FSMC_BWTR1..4)

Address offset: 0xA000 0000 + 0x104 + 8 * (x – 1), x = 1...4
Reset value: 0x0FFF FFFF

register นี้บรรจุ the control information ของแต่ละ memory bank, ที่ใช้สำหรับ SRAMs, PSRAM and NOR Flash memories. register นี้จะทำงานสำหรับ write asynchronous access เฉพาะเมื่อ the EXTMOD bit ถูกเซ็ตใน the FSMC_BCRx register



Bits 31:30 Reserved, must be kept at reset value.

Bits 29:28 ACCMOD[1:0]: Access mode
ระบุ the asynchronous access modes ดังแสดงใน the next timing diagrams. บิตเหล่านี้ถูกคำนึงถึงเฉพาะเมื่อ the EXTMOD bit ใน the FSMC_BCRx register เป็น 1.
     00: access mode A
     01: access mode B
     10: access mode C
     11: access mode D

Bits 27:20 Reserved, must be kept at reset value.

Bits 19:16 BUSTURN[3:0]: Bus turnaround phase duration
The programmed bus turnaround delay ถูกแทรกระหว่าง an asynchronous write transfer และ asynchronous/synchronous read หรือ write transfer อื่นใดๆ ไปยัง/จาก a static bank (สำหรับ a read operation, the bank สามารถเป็นตัวเดียวกันหรือตัวต่างกันก็ได้; สำหรับ a write operation, the bank สามารถเป็นตัวต่างกันยกเว้นใน muxed or D mode).

ในบางกรณี, the bus turnaround delay ถูกคงที่, อย่างใดก็ตาม the programmed BUSTURN values:
– ไม่มี bus turnaround delay ถูกแทรกระหว่าง two consecutive asynchronous write transfers ไปยัง the same static memory bank ยกเว้นใน muxed and D mode.
– A bus turnaround delay ของ 2 FSMC clock cycle ถูกแทรกระหว่าง:
      – Two consecutive synchronous write accesses (in burst or single mode) ไปยัง the same bank
      – A synchronous write transfer (in burst or single mode) และ an asynchronous write or read transfer ไปยังหรือ
         จาก static memory bank
– A bus turnaround delay of 3 FSMC clock cycles ถูกแทรกระหว่าง:
     – Two consecutive synchronous write accesses (in burst or single mode) ไปยัง static banks ตัวอื่น.
     – A synchronous write transfer (in burst or single mode) และ a synchronous read จาก the same หรือจาก a
        different bank.
     0000: BUSTURN phase duration = 1 HCLK clock cycle ถูกเพิ่ม
     ...
     1111: BUSTURN phase duration = 16 HCLK clock cycles added (default value after reset)

tha

Bits 15:8 DATAST[7:0]: Data-phase duration.
บิตเหล่านี้ถูกเขียนโดย software เพื่อกำหนด the duration ของ the data phase (อ้างอิงถึง Figure 187 ถึง Figure 199), ถูกใช้ใน asynchronous SRAM, PSRAM and NOR Flash memory accesses:
     0000 0000: Reserved
     0000 0001: DATAST phase duration = 2 × HCLK clock cycles
     0000 0010: DATAST phase duration = 3 × HCLK clock cycles
     ...
     1111 1111: DATAST phase duration = 16 × HCLK clock cycles (default value after reset)
Note: In synchronous accesses, ค่านี้ไม่ต้องสนใจ.

Bits 7:4 ADDHLD[3:0]: Address-hold phase duration.
บิตเหล่านี้ถูกเขียนโดย software เพื่อกำหนด the duration ของ the address hold phase (refer to Figure 196 to Figure 199), ถูกใช้ใน asynchronous multiplexed accesses:
     0000: Reserved
     0001: ADDHLD phase duration = 2 × HCLK clock cycle
     0010: ADDHLD phase duration = 3 × HCLK clock cycle
     ...
     1111: ADDHLD phase duration = 16 × HCLK clock cycles (default value after reset)
Note: In synchronous NOR Flash accesses, ค่านี้ไม่ถูกใช้, the address hold phase คือ 1 Flash clock period duration
          เสมอ.

Bits 3:0 ADDSET[3:0]: Address setup phase duration.
บิตเหล่านี้ถูกเขียนโดย software เพื่อกำหนด the duration ของ the address setup phase ใน HCLK cycles (refer to Figure 196 to Figure 199), ถูกใช้ใน asynchronous accessed:
     0000: ADDSET phase duration = 1 × HCLK clock cycle
     ...
     1111: ADDSET phase duration = 16 × HCLK clock cycles (default value after reset)
Note: In synchronous NOR Flash and PSRAM accesses, ค่านี้ไม่ต้องสนใจ.

tha

21.6 NAND Flash/PC Card controller

The FSMC สร้าง the appropriate signal timings เพื่อขับ device ประเภทต่อไปนี้:
• NAND Flash
– 8-bit
– 16-bit
• 16-bit PC Card compatible devices

The NAND/PC Card controller สามารถควบคุม three external banks. Bank 2 and bank 3 รองรับ NAND Flash devices. Bank 4 รองรับ PC Card devices.

แต่ละ bank ถูกกำหนดค่าโดยวิธีของ dedicated registers (Section 21.6.8 ). The programmable memory parameters รวมถึง access timings (แสดงใน Table 129) and ECC configuration.



tha

21.6.1 External memory interface signals

ตารางต่อไปนี้แสดงรายการ the signals ที่มักถูกใช้เพื่อเชื่อมต่อ NAND Flash and PC Card.

คำเตือน: เมื่อใช้ a PC Card หรือ a CompactFlash ใน I/O mode, the NIOS16 input pin ต้องยังคงอยู่ที่ ground level ในระหว่าง
               การทำงานทั้งหมด, มิฉะนั้นe the FSMC อาจไม่ทำงานอย่างเหมาะสม. นี้หมายความว่า the NIOS16 input pin ต้องไม่ถูกต่อ
               ถึง the card, แต่จะต่อโดยตรงถึง ground (เฉพาะ 16-bit accesses ที่ถูกยอมให้).

Note: คำนำหน้า "N". ระบุ the associated signal เป็น active low.



ไม่มี theoretical capacity limitation ดังที่ the FSMC สามารถจัดการ address cycles ได้มากมายตามต้องการ.


tha

21.6.2 NAND Flash / PC Card supported memories and transactions

Table 133 ข้างล่างแสดง the supported devices, access modes and transactions. Transactions ที่ไม่ยอมให้ (หรือไม่ถูกรองรับ) โดย the NAND Flash / PC Card controller จะปรากฎในสีเทา.


tha

21.6.3 Timing diagrams for NAND and PC Card

แต่ละ PC Card/CompactFlash and NAND Flash memory bank ถูกจัดการผ่านทางชุดของ registers:
•    Control register: FSMC_PCRx
•    Interrupt status register: FSMC_SRx
•    ECC register: FSMC_ECCRx
•    Timing register for Common memory space: FSMC_PMEMx
•    Timing register for Attribute memory space: FSMC_PATTx
•    Timing register for I/O space: FSMC_PIOx

แต่ละ timing configuration register บรรจุ three parameters ถูกใช้เพื่อกำหนดจำนวนของ HCLK cycles สำหรับ the three phases ของ any PC Card/CompactFlash or NAND Flash access, บวก one parameter ที่กำหนด the timing สำหรับสตาร์ทการขับ the databus ในกรณีของ a write. Figure 205 แสดง the timing parameter definitions สำหรับ common memory accesses, รู้ไว้ว่า Attribute และ I/O (เฉพาะสำหรับ PC Card) memory space access timings จะคล้ายกัน.


1. NOE ยังคง high (inactive) ในระหว่าง write access. NWE ยังคง high (inactive) ในระหว่าง read access.
2. NCEx ไปเป็น low ทันทีที่ NAND access ถูกร้องขอและยังคง low จนกระทั่ง a different(ตัวอื่น) memory bank ถูกเข้าถึง.

tha

21.6.4 NAND Flash operations

The command latch enable (CLE) และ address latch enable (ALE) signals ของ the NAND Flash device ถูกขับโดย some address signals ของ the FSMC controller. นี้หมายความว่าเพื่อส่ง a command หรือ an address ไปยัง the NAND Flash memory, the CPU ต้องดำเนินการ a write ไปยัง a certain address ใน memory space ของมัน.

A typical page read operation จาก the NAND Flash device ทำดังต่อไปนี้ :
1.    โปรแกรมและเปิดการใช้งาน the corresponding memory bank โดยการกำหนดค่า the FSMC_PCRx and FSMC_PMEMx
       (และสำหรับบาง devices, FSMC_PATTx, ดู Section 21.6.5) registers สอดคล้องกันกับคุณสมบัติของ the NAND Flash
       (PWID bits สำหรับ the databus width ของ the NAND Flash, PTYP = 1, PWAITEN = 0 or 1 ตามต้องการ, ดู Common
       memory space timing register 2..4 (FSMC_PMEM2..4) สำหรับ timing configuration).
2.    The CPU ดำเนินการ a byte write ใน the common memory space, ด้วย data byte ที่เท่ากับ one Flash command
       byte (ตัวอย่างเช่น 0x00 สำหรับ Samsung NAND Flash devices). The CLE input ของ the NAND Flash is active ใน
       ระหว่าง the write strobe (low pulse บน NWE), ดังนั้น the written byte ถูกตีความว่าเป็น a command โดย the NAND
       Flash. เมื่อ the command ถูก latched โดย the NAND Flash device, มันไม่จำเป็นที่ต้องถูกเขียนสำหรับ the following
       page read operations.
3.    The CPU สามารถส่ง the start address (STARTAD) สำหรับ a read operation โดยการเขียน the required bytes (ตัวอย่าง
       เช่น four bytes หรือ three สำหรับ smaller capacity devices), STARTAD[7:0], STARTAD[15:8], STARTAD[23:16]
       และสุดท้าย STARTAD[25:24] สำหรับ 64 Mb x 8 bit NAND Flash) ใน the common memory หรือ attribute space.
       The ALE input of the NAND Flash device is active ในระหว่าง the write strobe (low pulse บน NWE), ดังนั้น the
       written bytes ถูกตีความว่าเป็น the start address สำหรับ read operations. การใช้ the attribute memory space ทำให้
       สามารถใช้ a different timing configuration ของ the FSMC, ซึ่งสามารถถูกใช้เพื่อทำให้เป็นผล the prewait functionality
       ที่ต้องการโดย some NAND Flash memories (ดูรายละเอียดใน Section 21.6.5).
4.    The controller คอยสำหรับ the NAND Flash มีความพร้อม (R/NB signal high) เพื่อจะ active, ก่อนการสตาร์ท a new
       access (ไปยังตัวเดียวกันหรือ memory bank ตัวอื่น). ขณะที่คอย, the controller จะรักษา the NCE signal active (low).
5.    The CPU สามารถจากนั้นดำเนินการ byte read operations ใน the common memory space เพื่ออ่าน the NAND Flash
       page (data field + Spare field) byte by byte.
6.    The next NAND Flash page สามารถถูกอ่านโดยปราศจาก any CPU command หรือ address write operation, ในสามวิธีที่
       ต่างกัน :
       –    โดยดำเนินการอย่างง่ายๆ the operation ที่อธิบายใน step 5
       –    a new random address สามารถถูกเข้าถึงโดยการรีสตาร์ท the operation ที่ step 3
       –    a new command สามารถถูกส่งไปยัง the NAND Flash device โดยการรีสตาร์ทที่ step 2

tha

21.6.5 NAND Flash prewait functionality

Some NAND Flash devices ต้องการว่า, หลังจากการเขียน the last part of the address, the controller คอยสำหรับr the R/NB signal ไปเป็น low ดังแสดงใน Figure 206.


5. CPU เขียน byte A25-A24 ที่ address 0x7802 0000: FSMC ดำเนินการ a write access โดยใช้ FSMC_PATT2 timing definition, ที่ ATTHOLD ? 7 (จัดให้มีว่า (7+1) ≥ HCLK = 112 ns > tWB max). นี้กะรันตีว่า NCE ยังคง low จนกระทั่ง R/NB ไปเป็น low และ high อีกครั้ง (เฉพาะถูกร้องขอสำหรับ NAND Flash memories ที่ NCE ไม่สนใจไม่ได้).

เมื่อ functionality นี้ถูกต้องการ, มันสามารถถูกกะรันตีโดยการโปรแกรม the MEMHOLD value เพื่อให้ตรงตาม the tWB timing. อย่างไรก็ตาม CPU read accesses ไปยัง the NAND Flash memory มี a hold delay of (MEMHOLD + 2) x HCLK cycles, ในขณะที่ CPU write accesses มี a hold delay of (MEMHOLD) x HCLK cycles.

เพื่อเอาชนะ timing constraint นี้, the attribute memory space สามารถถูกใช้โดยการโปรแกรม timing register ของมันด้วย an ATTHOLD value ที่ตรงตาม the tWB timing, และทิ้งให้ the MEMHOLD value อยู่ที่ค่าต่ำสุดของมัน. ดังนั้น, the CPU ต้องใช้ the common memory space สำหรับ all NAND Flash read and write accesses, ยกเว้นเมื่อเขียน the last address byte ไปยัง the NAND Flash device, ที่ the CPU ต้องเขียนไปยัง the attribute memory space.