STM32F7 14 Quad-SPI interface (QUADSPI)

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

Previous topic - Next topic

tha

เมื่อ the FIFO ยังคงเต็มใน a read operation หรือถ้า the FIFO ยังคงว่างเปล่าใน a write operation, the operation จะหยุดและ CLK ยังคง low จนกว่า firmware จะบริการ the FIFO. ถ้า an abort เกิดขึ้นเมื่อ an operation ถูกหยุด, nCS จะพุ่งขึ้นเพีงหลังจาด the abort ถูกร้องขอและจากนั้น CLK จะพุ่งขึ้นครึ่งหนึ่งของ of a CLK cycle ต่อมา, ดังแสดงใน Figure 69.



เมื่อไม่อยู่ใน dual-flash mode (DFM = 0), เฉพาะ FLASH 1 ถูกเข้าถึงและดังนั้น the BK2_nCS ยังคงอยู่ high. ใน dual-flash mode, BK2_nCS จะทำงานเหมือนกับ BK1_nCS ทุกประการ. ดังนั้น, ถ้ามี a FLASH 2 และถ้า the application อยู่ใน dual-flash mode เสมอ, ดังนั้น FLASH 2 อาจใช้ BK1_nCS และ the pin ที่เอ๊าพุท BK2_nCS สามารถถูกใช้สำหรับฟังชั่นอื่น.

tha

14.4 QUADSPI interrupts

An interrupt สามารถถูกสร้างบน the following events:
•   Timeout
•   Status match
•   FIFO threshold
•   Transfer complete
•   Transfer error

Separate interrupt enable bits มีให้ใช้งานสำหรับความยืดหยุ่น.


tha

14.5 QUADSPI registers

14.5.1 QUADSPI control register (QUADSPI_CR)

Address offset: 0x0000
Reset value: 0x0000 0000



Bits 31:24 PRESCALER[7:0]: Clock prescaler
     ฟิลด์นี้กำหนด the scaler factor สำหรับสร้าง CLK ตั้งอยู่บน the AHB clock (value+1).
     0: FCLK = FAHB, AHB clock ถูกใช้โดยตรงเป็น QUADSPI CLK (prescaler ถูกข้ามผ่าน)
     1: FCLK = FAHB/2
     2: FCLK = FAHB/3
     ...
     255: FCLK = FAHB/256
     สำหรับ odd clock division factors, CLK's duty cycle ไม่เป็น 50%. The clock signal ยังคง low หนึ่ง cycle ยาวกว่าที่มันอยู่
     high.
     ฟิลด์นี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bit 23 PMM: Polling match mode
     บิตนี้แสดงให้เห็นวิธีที่ควรถูกใช้สำหรับกำหนด "คู่ที่เหมือนกัน" ในระหว่าง automatic polling mode.
     0: AND match mode. SMF จะถูกเซ็ตถ้า the unmasked bits ทั้งหมดที่รับจาก the Flash memory เป็นคู่ที่เหมือนกันกับ the
         corresponding bits ใน the match register.
     1: OR match mode. SMF จะถูกเซ็ตถ้า the unmasked bits บิตใดบิตหนึ่งที่รับจาก the Flash memory เป็นคู่ที่เหมือนกันกับ
         corresponding bit ของมันใน the match register.
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0

Bit 22 APMS: Automatic poll mode stop
     บิตนี้กำหนดว่า automatic polling จะถูกหยุดหรือไม่หลังจากมีคู่ที่เหมือนกัน.
     0: Automatic polling mode จะถูกหยุดเฉพาะโดย abort หรือโดยการปิดใช้งาน the QUADSPI.
     1: Automatic polling mode จะถูกทันทีที่มีคู่ที่เหมือนกัน.
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bit 21 Reserved, must be kept at reset value.

Bit 20 TOIE: TimeOut interrupt enable
     บิตนี้เปิดใช้งาน the TimeOut interrupt.
     0: Interrupt ถูกปิดใช้งาน
     1: Interrupt ถูกเปิดใช้งาน

Bit 19 SMIE: Status match interrupt enable
     บิตนี้เปิดใช้งาน the status match interrupt.
     0: Interrupt ถูกปิดใช้งาน
     1: Interrupt ถูกเปิดใช้งาน


tha

Bit 18 FTIE: FIFO threshold interrupt enable
     บิตนี้เปิดใช้งาน the FIFO threshold interrupt.
     0: Interrupt ถูกปิดใช้งาน
     1: Interrupt ถูกเปิดใช้งาน

Bit 17 TCIE: Transfer complete interrupt enable
     บิตนี้เปิดใช้งาน the transfer complete interrupt.
     0: Interrupt ถูกปิดใช้งาน
     1: Interrupt ถูกเปิดใช้งาน

Bit 16 TEIE: Transfer error interrupt enable
     บิตนี้เปิดใช้งาน the transfer error interrupt.
     0: Interrupt ถูกปิดใช้งาน
     1: Interrupt ถูกเปิดใช้งาน

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

Bits 12:8 FTHRES[4:0] FIFO threshold level
     กำหนด, ใน indirect mode, จำนวนขอบเขตของ bytes ใน the FIFO ที่จะเป็นเหตุให้ the FIFO threshold flag (FTF,
     QUADSPI_SR[2]) ถูกเซ็ต.
     ใน indirect write mode (FMODE = 00):
     0: FTF ถูกเซ็ตถ้ามี 1 bytes ขึ้นไปที่ว่างให้ใช้งานที่จะถูกเขียนลงใน the FIFO
     1: FTF ถูกเซ็ตถ้ามี 2 bytes ขึ้นไปที่ว่างให้ใช้งานที่จะถูกเขียนลงใน the FIFO
     ...
     31: FTF ถูกเซ็ตถ้ามี 32 bytes ขึ้นไปที่ว่างให้ใช้งานที่จะถูกเขียนลงใน the FIFO
     ใน indirect read mode (FMODE = 01):
     0: FTF ถูกเซ็ตถ้ามี 1 bytes ขึ้นไปที่ถูกต้องที่สามารถถูกอ่านจาก the FIFO
     1: FTF ถูกเซ็ตถ้ามี 2 bytes ขึ้นไปที่ถูกต้องที่สามารถถูกอ่านจาก the FIFO
     ...
     31: FTF ถูกเซ็ตถ้ามี 32 bytes ขึ้นไปที่ถูกต้องที่สามารถถูกอ่านจาก the FIFO
     ถ้า DMAEN = 1, ดังนั้น the DMA controller สำหรับ the corresponding channel ต้องถูกปิดใช้งานก่อนการเปลี่ยน the
     FTHRES value.

Bit 7 FSEL: Flash memory selection
     บิตนี้เลือก the Flash memory ที่จะถูกระบุที่อยู่ใน single flash mode (เมื่อ DFM = 0).
     0: FLASH 1 ถูกเลือก
     1: FLASH 2 ถูกเลือก
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.
     บิตนี้จะถูกเพิกเฉยเมื่อ DFM = 1.

Bit 6 DFM: Dual-flash mode
     บิตนี้ทำให้ทำงาน dual-flash mode, โดยที่ two external Flash memories ถูกใช้พร้อมกันเพื่อสองเท่า throughput and
     capacity.
     0: Dual-flash mode ถูกปิดใช้งาน
     1: Dual-flash mode ถูกเปิดใช้งาน
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bit 5 Reserved, must be kept at reset value.

tha

Bit 4 SSHIFT: Sample shift
     โดยค่าเริ่มต้น, the QUADSPI จะสุ่ม data ที่ 1/2 ของ a CLK cycle หลังจาก the data ถูกขับโดย the Flash memory. บิทนี้
     อนุญาตให้ the data ถูกสุ่มในภายหลังเพื่อพิจารณาสำหรับ external signal delays.
     0: No shift
     1: 1/2 cycle shift
     Firmware ต้องมั่นใจว่า SSHIFT = 0 เมื่ออยู่ใน DDR mode (เมื่อ DDRM = 1).
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bit 3 TCEN: Timeout counter enable
     บิตนี้ใช้ได้เฉพาะเมื่อ memory-mapped mode (FMODE = 11) ถูกเลือก. การทำให้ทำงานบิตนี้เป็นเหตุให้ the chip select
     (nCS) ถูกปลดปล่อย (และดังนั้นลดการบริโภค) ถ้าไม่มีการถูกเข้าถึงหลังจากช่วงระยะเวลาหนึ่ง, โดยที่เวลานี้ถูกกำหนดโดย
     TIMEOUT[15:0] (QUADSPI_LPTR).
     Enable the timeout counter.
     โดยค่าเริ่มต้น, 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) ดังนั้น nCS จะถูกปลดปล่อยหลังจาก a period of TIMEOUT[15:0] (QUADSPI_LPTR) cycles
     ได้ผ่านไปโดยไม่มีการเข้าถึงใดๆเนื่องจากเมื่อ the FIFO กลายมาเป็นเต็มด้วย prefetch data.
     0: Timeout counter ถูกปิดใช้งาน, และดังนั้น the chip select (nCS) ยังคงแอคทีฟอย่างไม่มีกำหนดหลังจาก an access ใน
         memory-mapped mode.
     1: Timeout counter ถูกเปิดใช้งาน, และดังนั้น the chip select จะถูกปลดปล่อยใน memory-mapped mode หลังจาก
         TIMEOUT[15:0] cycles ของไม่มีการใช้งาน Flash memory.
     บิตนี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bit 2 DMAEN: DMA enable
     ใน indirect mode, DMA สามารถถูกใช้เพื่อ input or output data โดยทาง the QUADSPI_DR register. DMA transfers ถูก
     เริ่มต้นเมื่อ the FIFO threshold flag, FTF, ถูกเซ็ต.
     0: DMA ถูกปิดใช้งานสำหรับ indirect mode
     1: DMA ถูกเปิดใช้งานสำหรับ indirect mode

Bit 1 ABORT: Abort request
     บิตนี้ยกเลิก the on-going command sequence. มันจะถูกรีเซ็ตโดยอัตโนมัติทันทีที่ the abort เสร็จสมบูรณ์.
     บิตนี้จะหยุด the current transfer.
     ใน polling mode หรือ memory-mapped mode, บิตนี้รีเซ็ต the APM bit หรือ the DM bit ด้วย.
     0: ไม่มีการยกเลิกถูกร้องขอ
     1: การยกเลิกถูกร้องขอ

Bit 0 EN: Enable
     เปิดใช้งาน the QUADSPI.
     0: QUADSPI ถูกปิดใช้งาน
     1: QUADSPI ถูกเปิดใช้งาน

tha

14.5.2 QUADSPI device configuration register (QUADSPI_DCR)

Address offset: 0x0004
Reset value: 0x0000 0000



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

Bits 20:16 FSIZE[4:0]: Flash memory size
     ฟิลด์นี้กำหนดขนาดของ 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 รวมกัน.
     ฟิลด์นี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

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

Bits 10:8 CSHT[2:0]: Chip select high time
     CSHT+1 กำหนดจำนวนต่ำสุดของ CLK cycles ซึ่ง the chip select (nCS) ต้องยังคง high ระหว่าง commands ที่ปล่อยออกไปยัง
     the Flash memory.
     0: nCS อยู่ high เป็นเวลาอย่างน้อย 1 cycle ระหว่าง Flash memory commands
     1: nCS อยู่ high เป็นเวลาอย่างน้อย 2 cycle ระหว่าง Flash memory commands
     ...
     7: nCS อยู่ high เป็นเวลาอย่างน้อย 8 cycle ระหว่าง Flash memory commands
     ฟิลด์นี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

Bits 7:1 Reserved, must be kept at reset value.

Bit 0 CKMODE: Mode 0 / mode 3
     บิตนี้ระบุระดับที่ CLK ใช้ระหว่าง commands (เมื่อ nCS = 1).
     0: CLK ต้องอยู่ low ในขณะที่ nCS เป็น high (chip select ถูกปลดปล่อย). สิ่งนี้เรียกว่า mode 0.
     1: CLK ต้องอยู่ high ในขณะที่ nCS เป็น high (chip select ถูกปลดปล่อย). สิ่งนี้เรียกว่า mode 3.
     ฟิลด์นี้สามารถถูกแก้ไขเฉพาะเมื่อ BUSY = 0.

tha

14.5.3 QUADSPI status register (QUADSPI_SR)

Address offset: 0x0008
Reset value: 0x0000 0000



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

Bits 13:8 FLEVEL[5:0]: FIFO level
     ฟิลด์นี้ให้จำนวนของ valid bytes ซึ่งกำลังถูกถือใน the FIFO. FLEVEL = 0 เมื่อ the FIFO ว่างเปล่า, และ 32 เมื่อมันเต็ม. ใน
     memory-mapped mode และใน automatic status polling mode, FLEVEL จะเป็นศูนย์.

Bits 7:6 Reserved, must be kept at reset value.

Bit 5 BUSY: Busy
     บิตนี้ถูกเซ็ตเมื่อ an operation กำลังดำเนินการอยู่. บิตนี้จะเคลียร์โดยอัตโนมัติเมื่อการทำงานกับ the Flash memory เสร็จสิ้นและ the
     FIFO ว่างเปล่า.

Bit 4 TOF: Timeout flag
     บิตนี้ถูกเซ็ตเมื่อ timeout เกิดขึ้น. มันจะถูกเคลียร์โดยการเขียน 1 ไปยัง CTOF.

Bit 3 SMF: Status match flag
     บิตนี้ถูกเซ็ตใน automatic polling mode เมื่อ the unmasked received data เป็นคู่ที่เหมือนกันกับ the corresponding bits
     ใน the match register (QUADSPI_PSMAR). มันจะถูกเคลียร์โดยการเขียน 1 ไปยัง CSMF.

Bit 2 FTF: FIFO threshold flag
     ใน indirect mode, บิตนี้ถูกเซ็ตเมื่อ the FIFO threshold ถูกถึงแล้ว, หรือถ้ามี data ใดๆเหลืออยู่ใน the FIFO หลังจากการอ่านจาก
     the Flash memory เสร็จสมบูรณ์. มันจะถูกเคลียร์โดยอัตโนมัติทันทีที่ threshold condition ไม่เป็นจริงอีกต่อไป.
     ใน automatic polling mode บิตนี้ถูกเซ็ตทุกครั้งที่ the status register ถูกอ่าน, และ the bit จะถูกเคลียร์เมื่อ the data
     register ถูกอ่าน.

Bit 1 TCF: Transfer complete flag
     บิตนี้ถูกเซ็ตใน indirect mode เมื่อจำนวนที่โปรแกรมของ data ถูกส่งถ่ายแล้วหรือใน mode ใดๆเมื่อ the transfer ถูกยกเลิก. มันจะ
     ถูกเคลียร์โดยการเขียน 1 ไปยัง CTCF.

Bit 0 TEF: Transfer error flag
     บิตนี้ถูกเซ็ตใน indirect mode เมื่อ an invalid address กำลังถูกเข้าถึงใน indirect mode. มันจะถูกเคลียร์โดยการเขียน 1 ไปยัง
     CTEF.

tha

14.5.4 QUADSPI flag clear register (QUADSPI_FCR)

Address offset: 0x000C
Reset value: 0x0000 0000



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

Bit 4 CTOF: Clear timeout flag
     การเขียน 1 จะเคลียร์ the TOF flag in the QUADSPI_SR register

Bit 3 CSMF: Clear status match flag
     การเขียน 1 จะเคลียร์ the SMF flag in the QUADSPI_SR register

Bit 2 Reserved, must be kept at reset value.

Bit 1 CTCF: Clear transfer complete flag
     การเขียน 1 จะเคลียร์ the TCF flag in the QUADSPI_SR register

Bit 0 CTEF: Clear transfer error flag
     การเขียน 1 จะเคลียร์ the TEF flag in the QUADSPI_SR register