STM32F7 13 Flexible memory controller (FMC)

Started by tha, November 10, 2022, 08:25:57 AM

Previous topic - Next topic

tha

Self-refresh mode

โหมดนี้ถูกเลือกโดยการเซ็ต the MODE bits เป็น '101' และโดยการกำหนดค่า the Target Bank bits (CTB1 and/or CTB2) ใน the FMC_SDCMR register.

The SDRAM clock หยุดการรันหลังจาก a TRAS delay และ the internal refresh timer หยุดการนับเฉพาะถ้าหนึ่งในเงื่อนไขต่อไปนี้ถูกตรงตาม:
•   A Self-refresh command ถูกปล่อยออกไปยังทั้งสอง devices
•   the devices ตัวใดตัวหนึ่งไม่ถูกทำให้ทำงาน (SDRAM bank ไม่ถูกเริ่มต้น).

ก่อนการเข้าสู่ Self-Refresh mode, the SDRAM controller จะปล่อยออกโดยอัตโนมัติ a PALL command.

ถ้า the Write data FIFO ไม่ว่างเปล่า, ทุก data จะถูกส่งไปยัง the memory ก่อนการทำให้ทำงาน the Self-refresh mode และ the BUSY status flag ยังคงเซ็ต.

ใน Self-refresh mode, ทุก SDRAM device inputs กลายมาเป็นไม่สนใจยกเว้นสำหรับ SDCKE ซึ่งยังคง low.

The SDRAM device ต้องยังคงอยู่ใน Self-refresh mode เป็นระยะเวลาขั้นต่ำที่ TRAS และสามารถยังคงอยู่ใน Self-refresh mode ได้เป็นระยะเวลาไม่จำกัดนอกเหนือจากนั้น. เพื่อรับประกันช่วงเวลาขั้นต่ำนี้, the BUSY status flag ยังคง high หลังจาก the Self-refresh activation ในระหว่าง a TRAS delay.

ทันทีที่ an SDRAM device ถูกเลือก, the SDRAM controller จะสร้างลำดับของ commands เพื่ออกจาก Self-refresh mode. หลังจาก the memory access, the selected device ยังคงอยู่ใน Normal mode.

เพื่อออกจาก Self-refresh, the MODE bits ต้องถูกเซ็ตเป็น '000' (Normal mode) และ the Target Bank bits (CTB1 and/or CTB2) ต้องถูกกำหนดค่าใน the FMC_SDCMR register.


tha

Power-down mode

โหมดนี้ถูกเลือกโดยการเซ็ต the MODE bits เป็น '110' และโดยการกำหนดค่า the Target Bank bits (CTB1 and/or CTB2) ใน the FMC_SDCMR register.



ถ้า the Write data FIFO ไม่ว่างเปล่า, ทุก data จะถูกส่งไปยัง the memory ก่อนการทำให้ทำงาน the Power-down mode.

ทันทีที่ an SDRAM device ถูกเลือก, the SDRAM controller จะออกจาก the Power-down mode. หลังจาก the memory access, the selected SDRAM device ยังคงอยู่ใน Normal mode.

ในระหว่าง Power-down mode, ทุก SDRAM device input and output buffers จะถูกทำให้ไม่ทำงานยกเว้นสำหรับ the SDCKE ซึ่งยังคง low.

The SDRAM device ไม่สามารถยังคงอยู่ใน Power-down mode ยาวนานกว่า the refresh period และไม่สามารถดำเนินการ the Auto-refresh cycles ด้วยตัวมันเอง. ดังนั้น, the SDRAM controller ทำให้สำเร็จ the refresh operation โดยการปฏิบัติการทำงานข้างล่าง:
1.   ออกจาก Power-down mode และขับ the SDCKE high
2.   สร้าง the PALL command เฉพาะถ้า a row เคยแอคทีฟในระหว่าง Power-down mode
3.   สร้าง the auto-refresh command
4.   ขับ SDCKE low อีกครั้งเพื่อคืนกลับไปยัง Power-down mode.

เพื่อออกจาก Power-down mode, the MODE bits ต้องถูกเซ็ตเป็น '000' (Normal mode) และ the Target Bank bits (CTB1 and/or CTB2) ต้องถูกกำหนดค่าใน the FMC_SDCMR register.

tha

13.7.5 SDRAM controller registers

SDRAM Control registers 1,2 (FMC_SDCR1,2)

Address offset: 0x140+ 4* (x – 1), x = 1,2
Reset value: 0x0000 02D0

register นี้บรรจุ the control parameters สำหรับแต่ละ SDRAM memory bank



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

Bits 14:13 RPIPE[1:0]: Read pipe
     บิตเหล่านี้กำหนด the delay, เป็น HCLK clock cycles, สำหรับการอ่าน data หลังจาก CAS latency.
     00: No HCLK clock cycle delay
     01: One HCLK clock cycle delay
     10: Two HCLK clock cycle delay
     11: reserved.
  Note:  บิตที่ตรงกันใน the FMC_SDCR2 register ถูกอ่านได้เท่านั้น.

Bit 12 RBURST: Burst read
     บิตนี้เปิดใช้งาน Burst read mode. The SDRAM controller จะคาดการณ์ the next read commands ในระหว่าง the CAS
     latency และเก็บ data ใน the Read FIFO.
     0: single read requests ไม่ถูกจัดการเป็น bursts(การส่งข้อมูลเป็นชุดอย่างเร็ว)
     1: single read requests  ถูกจัดการเป็น bursts เสมอ
  Note:  บิตที่ตรงกันใน the FMC_SDCR2 register ไม่ต้องสนใจ.

Bits 11:10 SDCLK[1:0]: SDRAM clock configuration
     บิตเหล่านี้กำหนด the SDRAM clock period สำหรับทั้งสอง SDRAM banks และยอมให้ปิดใช้งาน the clock ก่อนการเปลี่ยน the
     frequency. ในกรณีนี้ the SDRAM ต้องถูกเริ่มต้นใหม่.
     00: SDCLK clock disabled
     01: reserved
     10: SDCLK period = 2 x HCLK periods
     11: SDCLK period = 3 x HCLK periods
  Note:  บิตที่ตรงกันใน the FMC_SDCR2 register ไม่ต้องสนใจ.

Bit 9 WP: Write protection
     บิตนี้เปิดใช้งาน write mode access ไปยัง the SDRAM bank.
     0: Write accesses ถูกอนุญาต
     1: Write accesses ถูกเพิกเฉย

Bits 8:7 CAS[1:0]: CAS Latency
     บิตนี้เซ็ต the SDRAM CAS latency เป็นจำนวนของ memory clock cycles
     00: reserved.
     01: 1 cycle
     10: 2 cycles
     11: 3 cycles

Bit 6 NB: Number of internal banks
     บิตนี้เซ็ตจำนวนของ internal banks.
     0: Two internal Banks
     1: Four internal Banks

Bits 5:4 MWID[1:0]: Memory data bus width.
     บิตเหล่านี้กำหนด the memory device width.
     00: 8 bits
     01: 16 bits
     10: 32 bits
     11: reserved.

Bits 3:2 NR[1:0]: Number of row address bits
     บิตเหล่านี้กำหนดจำนวนของบิตของ a row address.
     00: 11 bit
     01: 12 bits
     10: 13 bits
     11: reserved.

Bits 1:0 NC[1:0]: Number of column address bits
     บิตเหล่านี้กำหนดจำนวนของบิตของ a column address.
     00: 8 bits
     01: 9 bits
     10: 10 bits
     11: 11 bits.

Note:  ก่อนการแก้ไข the RBURST or RPIPE การเซ็ตหรือการปิดใช้งาน the SDCLK clock, ก่อนอื่นผู้ใช้ต้องส่ง a PALL command
           เพื่อให้แน่ใจว่าการทำงานที่กำลังดำเนินการอยู่เสร็จสมบูรณ์.


tha

SDRAM Timing registers 1,2 (FMC_SDTR1,2)

Address offset: 0x148 + 4 * (x – 1), x = 1,2
Reset value: 0x0FFF FFFF

register นี้บรรจุ the timing parameters ของแต่ละ SDRAM bank



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

Bits 27:24 TRCD[3:0]: Row to column delay
     บิตเหล่านี้กำหนด the delay ระหว่าง the Activate command และ a Read/Write command เป็นจำนวนของ memory clock
     cycles.
     0000: 1 cycle.
     0001: 2 cycles
     ....
     1111: 16 cycles

Bits 23:20 TRP[3:0]: Row precharge delay
     บิตเหล่านี้กำหนด the delay ระหว่าง a Precharge command และ command อื่นอีกคำสั่งหนึ่งเป็นจำนวนของ memory clock
     cycles. The TRP timing ถูกกำหนดค่าเฉพาะใน the FMC_SDTR1 register. ถ้า two SDRAM devices ถูกใช้, the TRP ต้องถูก
     โปรแกรมด้วย the timing ของ the slowest device.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles
  Note: บิตที่ตรงกันใน the FMC_SDTR2 register ไม่ต้องสนใจ.

Bits 19:16 TWR[3:0]: Recovery delay
     บิตเหล่านี้กำหนด the delay ระหว่าง a Write and a Precharge command เป็นจำนวนของ memory clock cycles.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles
  Note:   TWR ต้องถูกโปรแกรมให้ตรงกับ the write recovery time (tWR) ที่กำหนดไว้ใน the SDRAM datasheet, และเพือรับ
             ประกันว่า:
             TWR ≥ TRAS - TRCD and TWR ≥TRC - TRCD - TRP
             Example: TRAS= 4 cycles, TRCD= 2 cycles. ดังนั้น, TWR >= 2 cycles. TWR ต้องถูกโปรแกรมเป็น 0x1.
             ถ้า two SDRAM devices ถูกใช้, the FMC_SDTR1 and FMC_SDTR2 ต้องถูกโปรแกรมด้วย the same TWR timing ที่
             ตรงกันกับ the slowest SDRAM device.
             ถ้ามีเพียง one SDRAM device ถูกใช้, the TWR timing ต้องถูกเก็บไว้ที่ reset value (0xF) สำหรับ the not used
             bank.


Bits 15:12 TRC[3:0]: Row cycle delay
     บิตเหล่านี้กำหนด the delay ระหว่าง the Refresh command and the Activate command, เช่นเดียวกับ the delay ระหว่าง
     two consecutive Refresh commands. มันถูกแสดงเป็นจำนวนของ memory clock cycles. The TRC timing ถูกกำหนดค่า
     เฉพาะใน the FMC_SDTR1 register. ถ้า two SDRAM devices ถูกใช้, the TRC ต้องถูกโปรแกรมด้วย the timings ของ the
     slowest device.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles
Note:  TRC ต้องตรงกับ the TRC and TRFC (Auto Refresh period) timings ที่กำหนดใน the SDRAM device datasheet.
  Note:  บิตที่ตรงกันใน the FMC_SDTR2 register ไม่ต้องสนใจ.

 
Bits 11:8 TRAS[3:0]: Self refresh time
     บิตเหล่านี้กำหนด the minimum Self-refresh period เป็นจำนวนของ memory clock cycles.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles

Bits 7:4 TXSR[3:0]: Exit Self-refresh delay
     บิตเหล่านี้กำหนด the delay จากการปลดปล่อย the Self-refresh command ถึงการปล่อยออก the Activate command เป็น
     จำนวนของ memory clock cycles.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles
   Note:  ถ้า two SDRAM devices ถูกใช้, the FMC_SDTR1 and FMC_SDTR2 ต้องถูกโปรแกรมด้วย the same TXSR timing ที่
             ตรงกันกับ the slowest SDRAM device.


Bits 3:0 TMRD[3:0]: Load Mode Register to Active
     บิตเหล่านี้กำหนด the delay ระหว่าง a Load Mode Register command และ an Active or Refresh command เป็นจำนวน
     ของ memory clock cycles.
     0000: 1 cycle
     0001: 2 cycles
     ....
     1111: 16 cycles

Note:  ถ้า two SDRAM devices ถูกต่อ, ทุก the accesses ถูกดำเนินการพร้อมกันไปยังทั้งสอง devices โดย the Command Mode
          register (Load Mode Register command) ถูกปล่อยออกโดยใช้ the timing parameters ที่กำหนดค่าสำหรับ Bank 1
          (TMRD and TRAS timings) ใน the FMC_SDTR1 register.

          The TRP and TRC timings ถูกกำหนดค่าเฉพาะใน the FMC_SDTR1 register. ถ้า two SDRAM devices ถูกใช้, the TRP
          and TRC timings ต้องถูกโปรแกรมด้วย the timings ของ the slowest device.

tha

SDRAM Command Mode register (FMC_SDCMR)

Address offset: 0x150
Reset value: 0x0000 0000

register นี้บรรจุ the command ที่ปล่อยออกเมื่อ the SDRAM device ถูกเข้าถึง. register นี้ถูกใช้เพื่อเริ่มต้น the SDRAM device, และเพื่อทำให้ทำงาน the Self-refresh และ the Power-down modes. ทันทีที่ the MODE field ถูกเขียน, the command จะถูกปล่อยออกเฉพาะถึงหนึ่งหรือถึงทั้งสอง SDRAM banks ตาม CTB1 and CTB2 command bits. register นี้เป็นเหมือนกันสำหรับทั้งสอง SDRAM banks.



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

Bits 21:9 MRD[12:0]: Mode Register definition
     13-bit field นี้กำหนด the SDRAM Mode Register content. The Mode Register ถูกโปรแกรมโดยใช้ the Load Mode
     Register command.

Bits 8:5 NRFS[3:0]: Number of Auto-refresh
     บิตเหล่านี้กำหนดจำนวนของ consecutive Auto-refresh commands ที่ปล่อยออกเมื่อ MODE = '011'.
     0000: 1 Auto-refresh cycle
     0001: 2 Auto-refresh cycles
     ....
     1110: 15 Auto-refresh cycles
     1111: 16 Auto-refresh cycles

Bit 4 CTB1: Command Target Bank 1
     บิตนี้แสดงให้เห็นว่า the command จะถูกปล่อยออกไปยัง SDRAM Bank 1 หรือไม่.
     0: Command  ไม่ถูกปล่อยออกไปยัง SDRAM Bank 1
     1: Command ถูกปล่อยออกไปยัง SDRAM Bank 1

Bit 3 CTB2: Command Target Bank 2
     บิตนี้แสดงให้เห็นว่า the command จะถูกปล่อยออกไปยัง SDRAM Bank 2 หรือไม่.
     0: Command  ไม่ถูกปล่อยออกไปยัง SDRAM Bank 2
     1: Command ถูกปล่อยออกไปยัง SDRAM Bank 2

Bits 2:0 MODE[2:0]: Command mode
     บิตเหล่านี้กำหนด the command ที่ปล่อยออกไปยัง the SDRAM device.
     000: Normal Mode
     001: Clock Configuration Enable
     010: PALL ("All Bank Precharge") command
     011: Auto-refresh command
     100: Load Mode Register
     101: Self-refresh command
     110: Power-down command
     111: Reserved

Note:  เมื่อ a command ถูกปล่อยออก, อย่างน้อยหนึ่ง Command Target Bank bit ( CTB1 or CTB2) ต้องถูกเว็ตมิฉะนั้น the
          command จะถูกเพิกเฉย.

Note:  ถ้า two SDRAM banks ถูกใช้, the Auto-refresh และ PALL command ต้องถูกปล่อยออกพร้อมกันไปยัง the two devices
          พร้อมด้วย CTB1 and CTB2 bits เซ็ตมิฉะนั้น the command จะถูกเพิกเฉย.

Note:  ถ้าเฉพาะหนึ่ง SDRAM bank ถูกใช้และ a command ถูกปล่อยออกพร้อมด้วย CTB bit ที่เกี่ยวข้องของมันเซ็ต, the other CTB
          bit ของ the unused bank ต้องถูกเก็บเป็น 0.

tha

SDRAM Refresh Timer register (FMC_SDRTR)

Address offset:0x154
Reset value: 0x0000 0000

register นี้เซ็ต the refresh rate เป็นจำนวนของ SDCLK clock cycles ระหว่าง the refresh cycles โดยการกำหนดค่า the Refresh Timer Count value.

                    Refresh rate = (COUNT + 1) × SDRAM clock frequency

                    COUNT = (SDRAM refresh period ⁄ Number of rows) – 20

Example

                   Refresh rate = 64 ms ⁄ (8196rows) = 7.81μs

โดยที่ 64 ms คือ the SDRAM refresh period.

                    7.81μs × 60MHz = 468.6

The refresh rate จะต้องเพิ่มขึ้น 20 SDRAM clock cycles (ดังในตัวอย่างข้างบน) เพื่อให้ได้รับกรอบที่ปลอดภัยถ้า an internal refresh request เกิดขึ้นเมื่อ a read request ถูกยอมรับแล้ว. มันตรงกันกับ a COUNT value of '0000111000000' (448).

This 13-bit field จะถูกโหลดลงใน a timer ซึ่งจะถูกทำให้ลดลงโดย the SDRAM clock. timer นี้จะสร้าง a refresh pulse เมื่อศูนย์ถูกถึง. The COUNT value ต้องถูกเซ็ตอย่างน้อยเป็น 41 SDRAM clock cycles.

ทันทีที่ the FMC_SDRTR register ถูกโปรแกรม, the timer จะสตาร์ทการนับ. ถ้า the value ที่โปรแกรมใน the register เป็น '0', จะไม่มี refresh ถูกทำให้สำเร็จ. register นี้ต้องไม่ถูกโปรแกรมใหม่หลังจากขั้นตอนการเริ่นต้นเพื่อหลีกเลี่ยงการแก้ไข the refresh rate.

แต่ละครั้งที่ a refresh pulse ถูกสร้าง, 13-bit COUNT field นี้จะถูกโหลดใหม่ลงใน the counter.

ถ้า a memory access กำลังดำเนินการอยู่, the Auto-refresh request จะถูกหน่วงเวลา. อย่างไรก็ตาม, ถ้า the memory access และ Auto-refresh requests ถูกสร้างขึ้นพร้อมกัน, the Auto-refresh จะได้รับลำดับที่เหนือกว่า. ถ้า the memory access เกิดขึ้นในระหว่าง a refresh operation, the request จะถูกบัฟเฟอร์จะถูกประมวลผลเมื่อ the refresh เสร็จสิ้น.

register ใช้ร่วมกันกับ SDRAM bank 1 and bank 2.



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

Bit 14 REIE: RES Interrupt Enable
     0: Interrupt ถูกปิดใช้งาน
     1: An Interrupt ถูกสร้างถ้า RE = 1

Bits 13:1 COUNT[12:0]: Refresh Timer Count
     13-bit field นี้กำหนด the refresh rate ของ the SDRAM device. มันถูกแสดงเป็นจำนวนของ memory clock cycles. มันต้อง
     ถูกเซ็ตอย่างน้อยเป็น 41 SDRAM clock cycles (0x29).
     Refresh rate = (COUNT + 1) x SDRAM frequency clock
     COUNT = (SDRAM refresh period / Number of rows) - 20

Bit 0 CRE: Clear Refresh error flag
     บิตนี้ถูกใช้เพื่อเคลียร์ the Refresh Error Flag (RE) ใน the Status Register.
     0: ไม่มีผลอะไร
     1: Refresh Error flag ถูกเคลียร์

Note:  The programmed COUNT value ต้องไม่เท่ากันกับผลรวมของเวลาต่อไปนี้:
           TWR+TRP+TRC+TRCD+4 memory clock cycles.

tha

SDRAM Status register (FMC_SDSR)

Address offset: 0x158
Reset value: 0x0000 0000



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

Bit 5 BUSY: Busy status
     บิตนี้กำหนด the status of the SDRAM controller หลังจาก a Command Mode request
     0: SDRAM Controller พร้อมที่จะยอมรับ a new request
     1; SDRAM Controller ไม่พร้อมที่จะยอมรับ a new request

Bits 4:3 MODES2[1:0]: Status Mode for Bank 2
     บิตนี้กำหนด the Status Mode of SDRAM Bank 2.
     00: Normal Mode
     01: Self-refresh mode
     10: Power-down mode

Bits 2:1 MODES1[1:0]: Status Mode for Bank 1
     บิตนี้กำหนด the Status Mode of SDRAM Bank 1.
     00: Normal Mode
     01: Self-refresh mode
     10: Power-down mode

Bit 0 RE: Refresh error flag
     0: ไม่มี refresh error ถูกตรวจพบ
     1: A refresh error ถูกตรวจพบแล้ว
     An interrupt จะถูกสร้างถ้า REIE = 1 และ RE = 1

tha