STM32F7 14 Quad-SPI interface (QUADSPI)

Started by tha, November 22, 2022, 02:04:44 PM

Previous topic - Next topic

tha

14.3.7 QUADSPI memory-mapped mode

เมื่อถูกกำหนดค่าใน memory-mapped mode, the external SPI device จะถูกมองว่าเป็น an internal memory

ห้ามมิให้เข้าถึง QUADSPI Flash bank area ก่อนที่จะมีการกำหนดค่าอย่างเหมาะสมและเปิดใช้งาน the QUADSPI peripheral.

ไม่มากกว่า 256MB สามารถระบุที่อยู่ถึงแม้ว่า the Flash memory capacity จะมากกว่าก็ตาม.

ถ้าการเข้าถึงถูกทำไปยัง an address ภายนอกของ the range ที่กำหนดโดย FSIZE แต่ยังคงอยู่ภายใน the 256MB range, ดังนั้น a bus error จะถูกให้. ผลของ error นี้จะขึ้นอยู่กับ the bus master ที่ถูกพยายามเข้าถึง:
•   ถ้ามันคือ the Cortex® CPU, bus fault exception จะถูกสร้างเมื่อเปิดใช้งาน (หรือ a hard fault exception เมื่อ bus fault ถูก
     ปิดใช้งาน)
•   ถ้ามันคือ a DMA, a DMA transfer error จะถูกสร้างและ the corresponding DMA channel จะถูกปิดใช้งานโดยอัตโนมัติ.

Byte, halfword, and word access types ถูกรองรับทั้งหมด.

รองรับสำหรับปฏิบัติ in place (XIP) operation ถูกจัดให้มีใช้, โดยที่ the QUADSPI จะคาดการณ์ the next microcontroller access และโหลดล่วงหน้า the byte ที่ the address ที่ตามมา. ถ้าการเข้าถึงในภายหลังถูกทำจริงๆที่ address ที่ต่อเนื่องกัน, the access จะเสร็จสมบูรณ์เร็วขึ้นเนื่องจาก the value ถูกดึงไว้ล่วงหน้าแล้ว.

โดยค่าเริ่มต้น, the QUADSPI ไม่เคยหยุด prefetch operation ของมัน, โดยจะเก็บ the previous read operation แอคทีฟด้วย nCS เก็บรักษา low ไว้, ถึงแม้ว่าไม่มีการเข้าถึงไปยัง the Flash memory เกิดขึ้นเป็นเวลายาวนาน. เนื่องจาก Flash memories มีแนวโน้มที่จะบริโภคมากขึ้นเมื่อ  nCS ถูกยึด low, the application อาจต้องการทำให้ทำงาน the timeout counter (TCEN = 1, bit 3 of QUADSPI_CR) ดังนั้น that nCS จะถูกปลดปล่อยหลังจาก a period of TIMEOUT[15:0] (QUADSPI_LPTR) cycles ได้ผ่านไปโดยไม่มีการเข้าถึงใดๆเนื่องจากเมื่อ the FIFO กลายมาเป็นเต็มด้วย prefetch data.

BUSY ไปเป็น high ทันทีที่ the first memory-mapped access เกิดขึ้น. เพราะว่า the prefetch operations, BUSY จะไม่ตกจนกว่าจะมี a timeout, มี an abort, หรือ the peripheral ถูกปิดใช้งาน.

tha

14.3.8 QUADSPI Flash memory configuration

The device configuration register (QUADSPI_DCR) สามารถถูกใช้เพื่อระบุ the characteristics of the external SPI Flash memory.

The FSIZE[4:0] field กำหนดขนาดของ external memory โดยใช้สูตรต่อไปนี้:

                    Number of bytes in Flash memory = 2^[FSIZE+1]

FSIZE+1 คือจำนวนของ address bits ที่ต้องการเพื่อระบุที่อยู่ the Flash memory. The Flash memory capacity สามารถมากถึง 4GB (ระบุที่อยู่โดยใช้ 32 bits) ใน indirect mode, แต่ the addressable space ใน memory-mapped mode ถูกจำกัดที่ 256MB.

ถ้า DFM = 1, FSIZE ระบุ the total capacity of the two Flash memories รวมกัน.

เมื่อ the QUADSPI ปฏิบัติ two commands, คำสั่งหนึ่งโดยทันทีหลังจากคำสั่งอื่น, มันจะยกขึ้น the chip select signal (nCS) เป็น high ระหว่าง the two commands เป็นเวลาเพียง one CLK cycle โดยค่าเริ่มต้น. ถ้า the Flash memory ต้องการเวลาที่มากขึ้นระหว่าง commands, the chip select high time (CSHT) field สามารถถูกใช้เพื่อระบุจำนวนต่ำสุดของ CLK cycles (มากถึง 8 ) ที่ nCS ต้องยังคง high.

The clock mode (CKMODE) bit ระบุ the CLK signal logic level ในระหว่าง commands (เมื่อ nCS = 1).

tha

14.3.9 QUADSPI delayed data sampling

โดยค่าเริ่มต้น, the QUADSPI จะสุ่ม the data ที่ขับโดย the Flash memory ครึ่งหนึ่งของ a CLK cycle หลังจาก the Flash memory ขับ the signal.

ในกรณีของ external signal delays, มันอาจเป็นประโยชน์ที่จะสุ่ม the data ภายหลัง. โดยใช้ the SSHIFT bit (bit 4 of QUADSPI_CR), the sampling of the data สามารถถูกเลื่อนไปครึ่งหนึ่งของ a CLK cycle.

Clock shifting ไม่ถูกรองรับใน DDR mode: the SSHIFT bit ต้องถูกเคลียร์เมื่อ DDRM bit ถูกเซ็ต.


tha

14.3.10 QUADSPI configuration

The QUADSPI configuration ถูกทำในสองขั้นตอน:
•   QUADSPI IP configuration
•   QUADSPI Flash memory configuration

ทันทีที่ถูกกำหนดค่าและถูกเปิดใช้งาน, the QUADSPI สามารถถูกใช้ใน three operating modes ของมัน: indirect mode, status-polling mode, or memory-mapped mode.

QUADSPI IP configuration

The QUADSPI IP ถูกกำหนดค่าโดยใช้ the QUADSPI_CR. ผู้ใช้จะต้องกำหนดค่า the clock prescaler division factor และ the sample shifting settings สำหรับ the incoming data.

DDR mode สามารถถูกเซ็ตผ่านทาง the DDRM bit. ทันทีที่ถูกเปิดใช้งาน, the address and the alternate bytes จะถูกส่งไปบนทั้งสอง clock edges และ the data ถูกส่ง/รับบนทั้งสอง clock edges. โดยไม่คำนึงถึง the DDRM bit setting, instructions จะถูกส่งใน SDR mode เสมอ.

The DMA requests ถูกเปิดใช้งานโดยการเซ็ต the DMAEN bit. ในกรณีของ interrupt usage, respective enable bit ของพวกมันสามารถถูกเซ็ตในระหว่างขั้นตอนนี้ด้วย.

FIFO level สำหรับอย่างใดอย่างหนึ่ง DMA request generation หรือ interrupt generation จะถูกโปรแกรมใน the FTHRES bits.

ถ้า timeout counter ถูกต้องการ, the TCEN bit สามารถถูกเซ็ตและ the timeout value จะถูกโปรแกรมใน the QUADSPI_LPTR register.

Dual-flash mode สามารถถูกทำให้ทำงานโดยการเซ็ต DFM เป็น 1.

QUADSPI Flash memory configuration

The parameters ที่เกี่ยวข้องกับ the targeted external Flash memory ถูกกำหนดค่าผ่านทาง the QUADSPI_DCR register. ผู้ใช้จะต้องโปรแกรม the Flash memory size ใน the FSIZE bits, the Chip Select minimum high time ใน the CSHT bits, และ the functional mode (Mode 0 หรือ Mode 3) ใน the MODE bit.

tha

14.3.11 QUADSPI usage

The operating mode ถูกเลือกโดยใช้ FMODE[1:0] (QUADSPI_CCR[27:26]).

Indirect mode procedure

เมื่อ FMODE ถูกโปรแกรมเป็น 00, indirect write mode จะถูกเลือกและ data สามารถถูกส่งไปยัง the Flash memory. ด้วย FMODE = 01, indirect read mode จะถูกเลือกโดยที่ data สามรถถูกอ่านจาก the Flash memory.

เมื่อ the QUADSPI ถูกใช้ใน indirect mode, the frames จะถูกสร้างขึ้นในวิธีต่อไปนี้:
1.   ระบุจำนวนของ data bytes ที่จะอ่านหรือเขียนใน the QUADSPI_DLR.
2.   ระบุ the frame format, mode และ instruction code ใน the QUADSPI_CCR.
3.   ระบุ optional alternate byte ที่จะถูกส่งทันทีหลังจาก the address phase ใน the QUADSPI_ABR.
4.   ระบุ the operating mode ใน the QUADSPI_CR. ถ้า FMODE = 00 (indirect write mode) และ DMAEN = 1, ดังนั้น
      QUADSPI_AR ควรถูกระบุก่อน QUADSPI_CR, เพราะมิฉะนั้น QUADSPI_DR อาจถูกเขียนโดย the DMA ก่อน QUADSPI_AR   
      ถูกอัฟเดต (ถ้า the DMA controller ถูกเปิดใช้งานแล้ว)
5.   ระบุ the targeted address ใน the QUADSPI_AR.
6.   อ่าน/เขียน the data จาก/ถึง the FIFO ผ่านทาง the QUADSPI_DR.

tha

เมื่อเขียน the control register (QUADSPI_CR) ผู้ใช้ระบุการเซ็ตต่อไปนี้:
•   The enable bit (EN) ถูกเซ็ตเป็น '1'
•   The DMA enable bit (DMAEN) สำหรับการส่งถ่าย data ถึง/จาก RAM
•   Timeout counter enable bit (TCEN)
•   Sample shift setting (SSHIFT)
•   FIFO threshold level (FTRHES) เพื่อระบุว่าเมื่อใด the FTF flag ควรถูกเซ็ต
•   Automatic polling mode parameters: match mode และ stop mode (ใช้ได้เมื่อ FMODE = 11)
•   Clock prescaler

tha

เมื่อเขียน the communication configuration register (QUADSPI_CCR) ผู้ใช้ระบุ the following parameters:
•   The instruction byte ผ่านทาง the INSTRUCTION bits
•   วิธีที่ the instruction ต้องถูกส่งผ่านทาง the IMODE bits (1/2/4 lines)
•   วิธีที่ the address ต้องถูกส่งผ่านทาง the ADMODE bits (ไม่มี/1/2/4 lines)
•   The address size (8/16/24/32-bit) ผ่านทาง the ADSIZE bits
•   วิธีที่ the alternate bytes ต้องถูกส่งผ่านทาง the ABMODE (ไม่มี/1/2/4 lines)
•   The alternate bytes number (1/2/3/4) ผ่านทาง the ABSIZE bits
•   การมีหรือไม่มี dummy bytes ผ่านทาง the DBMODE bit
•   จำนวนของ dummy bytes ผ่านทาง the DCYC bits
•   วิธีที่ the data ต้องถูกส่ง/ถูกรับ (ไม่มี/1/2/4 lines) ผ่านทาง the DMODE bits

tha

ถ้าไม่ทั้ง the address register (QUADSPI_AR) หรือ the data register (QUADSPI_DR) จำเป็นต้องถูกอัฟเดตสำหรับ a particular command, ดังนั้น the command sequence จะสตาร์ททันทีที่ QUADSPI_CCR ถูกเขียน. นี้เป็นกรณีเมื่อทั้ง ADMODE and DMODE เป็น 00, หรือถ้าเพียง ADMODE = 00 เมื่ออยู่ใน indirect read mode (FMODE = 01).

เมื่อ an address ถูกต้องการd (ADMODE ไม่ใช่ 00) และ the data register ไม่จำเป็ต้องถูกเขียน (เมื่อ FMODE = 01 หรือ DMODE = 00), the command sequence จะสตาร์ททันทีที่ the address ถูกอัฟเดตด้วยการเขียนไปยัง QUADSPI_AR.

ในกรณีของ data transmission (FMODE = 00 and DMODE! = 00), the communication start ถูกทริกโดยการเขียนใน the FIFO ผ่านทาง QUADSPI_DR.