STM32F1 FSMC

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

Previous topic - Next topic

tha

Wait management

สำหรับ synchronous NOR Flash memories, NWAIT ถูกตีค่าหลังจาก the programmed latency period, (DATLAT+2) CLK clock cycles.

ถ้า NWAIT ถูก sensed active (low level เมื่อ WAITPOL = 0, high level เมื่อ WAITPOL = 1), wait states ถูกแทรกจนกระทั่ง NWAIT ถูก sensed inactive (high level เมื่อ WAITPOL = 0, low level เมื่อ WAITPOL = 1).

เมื่อ NWAIT เป็น inactive, the data ถูกพิจารณาว่าถูกต้องทันที (bit WAITCFG = 1) หรือบน the next clock edge (bit WAITCFG = 0) อย่างใดอย่างหนึ่ง.

ในระหว่าง wait-state insertion โดยทาง the NWAIT signal, the controller ยังคงส่ง clock pulses ไปยัง the memory, ทำให้ the chip select and output enable signals ใช้ได้, และไม่ได้พิจารณาว่า the data ใช้ได้.

มี two timing configurations สำหรับ the NOR Flash NWAIT signal ใน burst mode:
•    Flash memory ยืนยัน the NWAIT signal หนึ่ง data cycle ก่อน the wait state (ค่าเริ่มต้นหลังจาก reset)
•    Flash memory ยืนยัน the NWAIT signal ในระหว่าง the wait state

two NOR Flash wait state configurations นี้ถูกรองรับโดย the FSMC, เป็นรายไปสำหรับแต่ละ chip select, เพราะ the WAITCFG bit ใน the FSMC_BCRx registers (x = 0..3).




1. Byte lane outputs BL ไม่ถูกแสดง; สำหรับ NOR access, พวกมันเป็น high, and, สำหรับ PSRAM (CRAM) access, พวกมันเป็น low.
2. NWAIT polarity ถูกเซ็ตเป็น 0.






1. Memory ต้องส่งออก NWAIT signal หนึ่ง cycle ล่วงหน้า, สอดคล้องกัน WAITCFG ต้องถูกโปรแกรมเป็น 0.
2. NWAIT polarity ถูกเซ็ตเป็น 0.
3. Byte Lane (NBL) outputs ไม่ถูกแสดง, พวกมันเป็น low ในขณะที่ NEx is active.




tha

21.5.6 NOR/PSRAM control registers

The NOR/PSRAM control registers ต้องถูกเข้าถึงโดย words (32 bits).

SRAM/NOR-Flash chip-select control registers 1..4 (FSMC_BCR1..4)

Address offset: 0xA000 0000 + 8 * (x – 1), x = 1...4
Reset value: 0x0000 30DB for Bank1 and 0x0000 30D2 for Bank 2 to 4

register นี้บรรจุ the control information ของแต่ละ memory bank, ใช้สำหรับ SRAMs, PSRAM and NOR Flash memories.



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

Bit 19 CBURSTRW: Write burst enable.
สำหรับ Cellular RAM (PSRAM) memories, บิตนี้เปิดการใช้งาน the synchronous burst protocol ในระหว่าง write operations. The enable bit สำหรับ synchronous read accesses คือ the BURSTEN bit ใน the FSMC_BCRx register.
     0: Write operations ถูกดำเนินการใน asynchronous mode เสมอ
     1: Write operations ถูกดำเนินการใน synchronous mode.

Bits 18: 16 CPSIZE[2:0]: CRAM page size.
เหล่านี้ถูกใช้สำหรับ Cellular RAM 1.5 ซึ่งไม่ยอมให้ burst access ข้าม the address boundaries ระหว่าง pages. เมื่อบิตเหล่านี้ถูกกำหนดค่า, the FSMC controller แยก the burst access โดยอัตโนมัติเมื่อ the memory page size ถูกถึง (อ้างอิงถึง memory datasheet สำหรับ page size).
     000: ไม่มี burst split เมื่อข้าม page boundary (ค่าเริ่มต้นหลังจาก reset)
     001: 128 bytes
     010: 256 bytes
     011: 512 bytes
     100: 1024 bytes
     อื่นๆ: สงวนไว้.

Bit 15 ASYNCWAIT: Wait signal during asynchronous transfers
บิตนี้ enables/disables the FSMC เพื่อใช้ the wait signal แม้ในระหว่าง an asynchronous protocol.
     0: NWAIT signal ไม่ถูกคำนึงถึงเมื่อกำลังรัน an asynchronous protocol (ค่าเริ่มต้นหลังจาก reset)
     1: NWAIT signal ถูกคำนึงถึงเมื่อกำลังรัน an asynchronous protocol

tha

Bit 14 EXTMOD: Extended mode enable.
บิตนี้เปิดการใช้งาน the FSMC เพื่อโปรแกรม the write timings สำหรับ non-multiplexed asynchronous accesses ภายใน the FSMC_BWTR register, ดังนั้นเป็นผลให้ different timings สำหรับ read and write operations.
     0: values ภายใน FSMC_BWTR register ไม่ถูกคำนึงถึง (ค่าเริ่มต้นหลังจาก reset)
     1: values inside FSMC_BWTR register ถูกคำนึงถึง
Note: เมื่อ the extended mode ถูก disabled, the FSMC สามารถทำงานใน Mode1 or Mode2 ดังต่อไปนี้:
           – Mode 1 คือ the default mode เมื่อ the SRAM/PSRAM memory type ถูกเลือก (MTYP [0:1]=0x0 or 0x01)
           – Mode 2 คือ the default mode เมื่อ the NOR memory type ถูกเลือก (MTYP [0:1]= 0x10).

Bit 13 WAITEN: Wait enable bit.
บิตนี้ enables/disables wait-state insertion โดยทาง the NWAIT signal เมื่อเข้าถึง the Flash memory ใน synchronous mode.
     0: NWAIT signal ถูก disabled ( level ของมันไม่ถูกคำนึงถึง, ไม่มี wait state ถูกแทรกหลังจาก the programmed Flash
          latency period)
     1: NWAIT signal ถูก enabled (level ของมันถูกคำนึงถึงหลังจาก the programmed Flash latency period แทรก wait
          states ถ้าถือสิทธิ์) (ค่าเริ่มต้นหลังจาก reset)

Bit 12 WREN: Write enable bit.
บิตนี้แสดงให้เห็นว่า write operations ถูก enabled/disabled ใน the bank โดย the FSMC:
     0: Write operations ถูก disabled ใน the bank โดย the FSMC, an AHB error ถูกรายงาน,
     1: Write operations ถูก enabled สำหรับ the bank โดย the FSMC (ค่าเริ่มต้นหลังจาก reset)


tha

Bit 11 WAITCFG: Wait timing configuration.
The NWAIT signal แสดงให้เห็นว่า the data จาก the memory ใช้ได้หรือถ้า a wait state ต้องถูกแทรกเมื่อเข้าถึง the Flash memory ใน synchronous mode. configuration bit นี้ตัดสินว่าถ้า NWAIT ถูกถือสิทธิ์โดย the memory หนึ่ง clock cycle ก่อน the wait state หรือในระหว่าง the wait state:
     0: NWAIT signal is active หนึ่ง data cycle ก่อน wait state (default after reset),
     1: NWAIT signal is active ในระหว่าง wait state (ไม่ถูกใช้สำหรับ PRAM).

Bit 10 WRAPMOD: Wrapped burst mode support.
กำหนดว่า the controller จะแยกหรือไม่แยก an AHB burst wrap access ลงใน two linear accesses. ใช้ได้เฉพาะเมื่อเข้าถึง memories ใน burst mode
     0: Direct wrapped burst ไม่ถูก enabled (default after reset),
     1: Direct wrapped burst ถูก enabled.
Note: บิตนี้ไม่มีผลตาม the CPU and DMA ที่ไม่สามารถสร้าง wrapping burst transfers.

Bit 9 WAITPOL: Wait signal polarity bit.
กำหนด the polarity ของ the wait signal จาก memory. ใช้ได้เฉพาะเมื่อเข้าถึง memories ใน burst mode:
     0: NWAIT active low (default after reset),
     1: NWAIT active high.

Bit 8 BURSTEN: Burst enable bit.
บิตนี้ enables/disables synchronous accesses ในระหว่าง read operations. มันใช้ได้เฉพาะสำหรับ synchronous memories ทำงานใน burst mode:
     0: Burst mode disabled (default after reset). Read accesses ถูกดำเนินการใน asynchronous mode.
     1: Burst mode enable. Read accesses ถูกดำเนินการใน synchronous mode.

tha

Bit 7 Reserved, must be kept at reset value.

Bit 6 FACCEN: Flash access enable
เปิดการใช้งาน NOR Flash memory access operations.
     0: Corresponding NOR Flash memory access ถูก disabled
     1: Corresponding NOR Flash memory access ถูก enabled (default after reset)

Bits 5:4 MWID[1:0]: Memory databus width.
กำหนด the external memory device width, ใช้ได้สำหรับ all type of memories.
     00: 8 bits,
     01: 16 bits (default after reset),
     10: สงวนไว้, ห้ามใช้,
     11: สงวนไว้, ห้ามใช้.

Bits 3:2 MTYP[1:0]: Memory type.
กำหนด the type of external memory ที่ต่อถึง the corresponding memory bank:
     00: SRAM (ค่าเริ่มต้นหลังจาก reset for Bank 2...4)
     01: PSRAM (CRAM)
     10: NOR Flash(default after reset for Bank 1)
     11: reserved

Bit 1 MUXEN: Address/data multiplexing enable bit.
เมื่อบิตนี้ถูกเซ็ต, the address and data values ถูก multiplexed บน the databus, ใช้ได้เฉพาะกับ NOR and PSRAM memories:
     0: Address/Data nonmultiplexed
     1: Address/Data multiplexed on databus (default after reset)

Bit 0 MBKEN: Memory bank enable bit.
เปิดการใช้งาน the memory bank. หลังจากรีเซ็ต Bank1 ถูก enabled, อื่นๆทั้งหมดถูก disabled. การเข้าถึง a disabled bank เป็นเหตุให้เกิด an ERROR บน AHB bus.
     0: Corresponding memory bank ถูก disabled
     1: Corresponding memory bank ถูก enabled

tha

SRAM/NOR-Flash chip-select timing registers 1..4 (FSMC_BTR1..4)

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

FSMC_BTRx bits ถูกเขียนโดย software เพื่อเพิ่ม a delay ที่ the end of a read /write transaction. delay นี้ยอมให้การจับคู่ the minimum time ระหว่าง consecutive transactions (tEHEL จาก NEx high ไปยัง FSMC_NEx low) และ the maximum time ที่ต้องการโดย the memory เพื่อปล่อยเป็นอิสระ the data bus หลังจาก a read access (tEHQZ).

register นี้บรรจุ the control information ของแต่ละ memory bank, ที่ใช้สำหรับr SRAMs, PSRAM and NOR Flash memories. ถ้า the EXTMOD bit ถูกเซ็ตใน the FSMC_BCRx register, ดังนั้น register นี้ถูกแยกสำหรับ write และ read access, นั่นคือ, 2 registers มีให้ใช้งาน: หนึ่งเพื่อกำหนดค่า read accesses (this register) และหนึ่งเพื่อกำหนดค่า write accesses
(FSMC_BWTRx registers).



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

Bits 29:28 ACCMOD[1:0]: Access mode
ระบุ the asynchronous access modes ดังแสดงใน the 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:24 DATLAT[3:0]: Data latency for synchronous NOR Flash memory (ดู note ข้างล่าง bit description table)
สำหรับ synchronous NOR Flash memory พร้อมด้วย burst mode ถูกเปิดการใช้งาน, กำหนดจำนวนของ memory clock cycles (+2) เพื่อปล่อยออกไปยัง the memory ก่อน reading/writing the first data. timing parameter นี้ไม่ถูกแสดงใน HCLK periods, แต่ใน FSMC_CLK periods. ในกรณีของ PSRAM (CRAM), field นี้ต้องถูกเซ็ตเป็น 0. ใน asynchronous NOR Flash หรือ SRAM หรือ PSRAM , ค่านี้ไม่ต้องสนใจ.
     0000: Data latency of 2 CLK clock cycles for first burst access
     1111: Data latency of 17 CLK clock cycles for first burst access (default value after reset)

Bits 23:20 CLKDIV[3:0]: Clock divide ratio (for FSMC_CLK signal)
กำหนดคาบเวลาของ of FSMC_CLK clock output signal, ที่แสดงในจำนวนของ HCLK cycles:
     0000: Reserved
     0001: FSMC_CLK period = 2 × HCLK periods
     0010: FSMC_CLK period = 3 × HCLK periods
     1111: FSMC_CLK period = 16 × HCLK periods (default value after reset)
ใน asynchronous NOR Flash, SRAM or PSRAM accesses, ค่านี้ไม่ต้องสนใจ.

tha

Bits 19:16 BUSTURN[3:0]: Bus turnaround phase duration
บิตเหล่านี้ถูกเขียนโดย software เพื่อเพิ่ม a delay ที่ the end ของ a write-to-read (และ read-to-write) transaction. The programmed bus turnaround delay ถูกแทรกระหว่าง an asynchronous read (muxed or D mode) หรือ a write transaction และ asynchronous/synchronous read หรือ write อื่นใดๆ ไปยัง/จาก 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 ของ 1 FSMC clock cycle ถูกแทรกระหว่าง:
     – Two consecutive asynchronous read transfers ไปยัง the same static memory bank ยกเว้นสำหรับ muxed and D
        modes.
     – An asynchronous read ไปยัง an asynchronous หรือ synchronous write ไปยัง static bank ใดๆ หรือ dynamic bank
        ยกเว้นสำหรับ muxed and D modes.
     – An asynchronous (modes 1, 2, A, B or C) read และ a read operation จาก static bank อื่น.
– A bus turnaround delay of 2 FSMC clock cycles ถูกแทรกระหว่าง:
     – Two consecutive synchronous write accesses (in burst or single mode) ไปยัง the same bank
     – A synchronous write (burst or single) access และ an asynchronous write or read transfer ไปยังหรือจาก static
        memory bank (the bank สามารถเป็นตัวเดียวกันหรือตัวต่างกันก็ได้ในกรณีของ a read operation).
     – Two consecutive synchronous read accesses (in burst or single mode) ตามด้วย a synchronous/asynchronous
        read หรือ write ใดๆ จาก/ไปยัง static memory bank อื่น.
– A bus turnaround delay of 3 FSMC clock cycles ถูกแทรกระหว่าง:
     – Two consecutive synchronous write operations (in burst or single mode) ไปยัง static banks ตัวอื่น.
     – A synchronous write access (in burst or single mode) และ a synchronous read access จาก the same หรือไปยัง
        a different bank.
     0000: BUSTURN phase duration = 1 HCLK clock cycle ถูกเพิ่ม
     ...
     1111: BUSTURN phase duration = 16 × HCLK clock cycles (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 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 = 256 × HCLK clock cycles (default value after reset)
สำหรับแต่ละ memory type and access mode data-phase duration, อ้างอิงถึง the respective figure (Figure 187 to Figure 199).
Example: Mode1, read access, DATAST=1: Data-phase duration= DATAST+3 = 4 HCLK clock cycles.
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), ถูกใช้ใน mode D and 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)
สำหรับแต่ล access mode address-hold phase duration, refer to the respective figure (Figure 196 to Figure 199).
Example: ModeD, read access, ADDHLD=1: Address-hold phase duration = ADDHLD + 1 =2 HCLK clock cycles.
Note: In synchronous accesses, ค่านี้ไม่ถูกใช้, the address hold phase เป็น 1 memory clock period duration เสมอ.

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

Note: PSRAMs (CRAMs) มี a variable latency เนื่องจาก internal refresh. ดังนั้น memories เหล่านี้ปล่อยออก the NWAIT
           signal ในระหว่าง the whole latency phase เพื่อยืดเวลา the latency ตามต้องการ.

           ในส่วน PSRAMs (CRAMs) the DATLAT field ต้องถูกเซ็ตเป็น 0, ดงนั้น the FSMC ออกจาก latency phase ของมันทันที
           และสตาร์ทการสุ่มจับ NWAIT จาก memory, จากนั้นสตาร์ทการ read or write เมื่อ the memory มีความพร้อม.

           วิธีนี้สามารถถูกใช้กับรุ่นล่าสุดของ synchronous Flash memories ได้อีกด้วย, ที่ปล่อยออก the NWAIT signal, ไม่เหมือน
           Flash memories รุ่นเก่ากว่า (เช็ค the datasheet of the specific Flash memory ที่ถูกใช้).