Electoday 2025

ไมโครคอนโทรลเลอร์ => ARM Processors => Topic started by: tha on November 22, 2022, 02:04:44 PM

Title: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 22, 2022, 02:04:44 PM
14 Quad-SPI interface (QUADSPI)

14.1 Introduction

The QUADSPI คือ a specialized communication อินเตอร์เฟสเป้าหมาย single, dual หรือ quad SPI Flash memories. มันสามารถทำงานหนึ่่งใน the three following modes:
•   indirect mode: ทุก the operations ถูกดำเนินการโดยใช้ the QUADSPI registers
•   status polling mode: the external Flash memory status register จะถูกอ่านเป็นระยะๆและ an interrupt สามารถถูกสร้างใน
     กรณีที่มีการเซ็ต flag
•   memory-mapped mode: the external Flash memory ถูกแม็ปเข้ากับ the microcontroller address space และถูกมอง
     โดย the system ราวกับว่ามันเป็น an internal memory

ทั้งปริมาณงานและความจุสามารถถูกเพิ่มขึ้นเป็นสองเท่าโดยใช้ dual-flash mode, โดยที่ two Quad-SPI Flash memories ถูกเข้าถึงพร้อมกัน.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 22, 2022, 03:01:06 PM
14.2 QUADSPI main features

•   Three functional modes: indirect, status-polling, and memory-mapped
•   Dual-flash mode, โดยที่ 8 bits สามารถถูกส่ง/รับพร้อมกันโดยการเข้าถึง two Flash memories ขนานกันไป.
•   SDR and DDR support
•   Fully programmable opcode สำหรับทั้ง indirect and memory mapped mode
•   Fully programmable frame format สำหรับทั้ง indirect and memory mapped mode
•   Integrated FIFO สำหรับ reception and transmission
•   8, 16, and 32-bit data accesses ถูกอนุญาต
•   DMA channel สำหรับ indirect mode operations
•   Interrupt generation บน FIFO threshold, timeout, operation เสร็จสิ้น, และ access error
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 22, 2022, 03:08:13 PM
14.3 QUADSPI functional description

14.3.1 QUADSPI block diagram

(https://i.imgur.com/eUfH0NZ.png)

(https://i.imgur.com/qMLPOii.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 22, 2022, 03:14:43 PM
14.3.2 QUADSPI pins

Table 90 แสดงรายการ the QUADSPI pins, หกสำหรับการอินเตอร์เฟสกับ a single Flash memory, หรือ 10 ถึง 11 สำหรับการอินเตอร์เฟสกับ two Flash memories (FLASH 1 and FLASH 2) ใน dual-flash mode.

(https://i.imgur.com/DZyZlXm.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 08:46:47 AM
14.3.3 QUADSPI command sequence

The QUADSPI สื่อสารกับ the Flash memory โดยใช้ commands. แต่ละ command สามารถประกอบด้วย 5 phases: instruction, address, alternate byte, dummy, data. ใดๆของ phases เหล่านี้สามารถถูกกำหนดค่าเพื่อที่จะถูกข้าม, แต่อย่างน้อยหนึ่งของ the instruction, address, alternate byte, หรือ data phase ต้องมีอยู่.

nCS จะตกก่อนการสตาร์ทของแต่ละ command และพุ่งขึ้นอีกครั้งหลังจากแต่ละ command เสร็จสิ้น.

(https://i.imgur.com/c9Eqaad.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 09:27:43 AM
Instruction phase

ในระหว่าง phase นี้, an 8-bit instruction, ที่กำหนดค่าใน INSTRUCTION field ของ QUADSPI_CCR[7:0] register, จะถูกส่งไปยัง the Flash memory, ระบุประเภทของการทำงานที่จะถูกดำเนินการ.

แม้ว่า Flash memories ส่วนใหญ่สามารถรับ instructions หนึ่งบิตในแต่ละครั้งจาก the IO0/SO signal (single SPI mode), the instruction phase สามารถมีทางเลือกส่ง 2 bits ในแต่ละครั้ง (บน IO0/IO1 ใน dual SPI mode) หรือ 4 bits ในแต่ละครั้ง (บน IO0/IO1/IO2/IO3 ใน quad SPI mode). นี้สามารถถูกกำหนดค่าโดยใช้ the IMODE[1:0] field ของ QUADSPI_CCR[9:8] register.

เมื่อ IMODE = 00, the instruction phase จะถูกข้าม, และ the command sequence จะสตาร์ทด้วย the address phase, ถ้ามีอยู่.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 09:58:53 AM
Address phase

ใน the address phase, 1-4 bytes ถูกส่งไปยัง the Flash memory เพื่อระบุ the address of the operation. จำนวนของ address bytes ที่จะถูกส่งถูกกำหนดค่าใน the ADSIZE[1:0] field of QUADSPI_CCR[13:12] register. ใน indirect and automatic-polling modes, the address bytes ที่จะถูกส่งถูกระบุใน the ADDRESS[31:0] field of QUADSPI_AR register, ในขณะที่ใน memory-mapped mode the address ถูกให้โดยตรงโดยทาง the AHB (จาก the Cortex® หรือจาก a DMA).

The address phase สามารถส่ง 1 bit ในแต่ละครั้ง (บน SO ใน single SPI mode), 2 bits ในแต่ละครั้ง(บน IO0/IO1 ใน dual SPI mode), หรือ 4 bits ในแต่ละครั้ง (บน IO0/IO1/IO2/IO3 ใน quad SPI mode). นี้สามารถถูกกำหนดค่าโดยใช้ the ADMODE[1:0] field of QUADSPI_CCR[11:10] register.

เมื่อ ADMODE = 00, the address phase จะถูกข้าม, และ the command sequence จะดำเนินการต่อโดยตรงไปยังเฟสถัดไป ถ้ามี
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 10:44:51 AM
Alternate-bytes phase

ใน the alternate-bytes phase, 1-4 bytes จะถูกส่งไปยัง the Flash memory, โดยทั่วไปเพื่อควบคุม the mode of operation. จำนวนของ alternate bytes ที่จะถูกส่งถูกกำหนดค่าใน the ABSIZE[1:0] field of QUADSPI_CCR[17:16] register. The bytes ที่จะถูกส่งถูกระบุใน the QUADSPI_ABR register.

The alternate-bytes phase สามารถส่ง 1 bit ในแต่ละครั้ง (บน SO ใน single SPI mode), 2 bits ในแต่ละครั้ง (บน IO0/IO1 ใน dual SPI mode), หรือ 4 bits ในแต่ละครั้ง (บน IO0/IO1/IO2/IO3 ใน quad SPI mode). นี้สามารถถูกกำหนดค่าโดยใช้ the ABMODE[1:0] field of QUADSPI_CCR[15:14] register.

เมื่อ ABMODE = 00, the alternate-bytes phase จะถูกข้าม, และ the command sequence จะดำเนินการต่อโดยตรงไปยังเฟสถัดไป ถ้ามี.

อาจมีบางครั้งที่เฉพาะ a single nibble จำเป็นต้องถูกส่งในระหว่าง the alternate-byte phase แทนที่จะเป็น a full byte, อย่างเช่นเมื่อ dual-mode ถูกใช้และมีเพียง two cycles ถูกใช้สำหรับ the alternate bytes. ในกรณีนี้, firmware สามารถใช้ quad-mode (ABMODE = 11) และส่ง a byte ที่มี bits 7 and 3 of ALTERNATE ถูกเซ็ตเป็น '1' (ทำให้ the IO3 line high), และ bits 6 and 2 ถูกเซ็ตเป็น '0' (ทำให้ the IO2 line low). ในกรณีนี้ the upper two bits ของ the nibble ที่จะถูกส่งถูกวางใน bits 4:3 ของ ALTERNATE ในขณะที่ the lower two bits จะถูกวางใน bits 1 and 0. ตัวอย่างเช่น, ถ้า the nibble 2 (0010) จะถูกส่งบน IO0/IO1, ดังนั้น ALTERNATE ควรถูกเซ็ตเป็น 0x8A (1000_1010).
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 11:10:20 AM
Dummy-cycles phase

ใน the dummy-cycles phase, 1-31 cycles ถูกให้โดยไม่มี data ใดๆถูกส่งหรือถูกรับ, เพื่ออนุญาตให้ the Flash memory มีเวลาเตรียมสำหรับ the data phase เมื่อ higher clock frequencies ถูกใช้. จำนวนของ cycles ที่ให้ในระหว่าง phase นี้ถูกระบุใน the DCYC[4:0] field ของ QUADSPI_CCR[22:18] register. ในทั้ง SDR and DDR modes, the duration ถูกระบุเป็นจำนวนของ full CLK cycles.

เมื่อ DCYC เป็นศูนย์, the dummy-cycles phase จะถูกข้าม, และ the command sequence จะดำเนินการต่อโดยตรงไปยัง the data phase, ถ้ามี.

The operating mode of the dummy-cycles phase ถูกกำหนดโดย DMODE.

เพื่อให้มั่นใจว่าจะมีเวลา "กลับตัว" เพียงพอสำหรับการเปลี่ยน the data signals จาก output mode ไปเป็น input mode, ต้องมีอย่างน้อย one dummy cycle เมื่อใช้ dual or quad mode เพื่อรับ data จาก the Flash memory.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 23, 2022, 11:49:40 AM
Data phase

ในระหว่าง the data phase, จำนวนใดๆของ bytes สามารถูกส่งถึง, หรือรับจาก the Flash memory.

ใน indirect and automatic-polling modes, จำนวนของ bytes ที่จะถูกส่ง/ถูกรับถูกระบุไว้ใน the QUADSPI_DLR register.

ใน indirect write mode the data ที่จะถูกส่งไปยัง the Flash memory ต้องถูกเขียนลงใน the QUADSPI_DR register, ในขณะที่ใน indirect read mode the data ที่รับจาก the Flash memory ได้รับโดยการอ่านจาก the QUADSPI_DR register.

ใน memory-mapped mode, the data ซึ่งถูกอ่านจะถูกส่งกลับโดยตรงไปบน the AHB ไปยัง the Cortex หรือไปยัง a DMA.

The data phase สามารถส่ง/รับ 1 bit ในแต่ละครั้ง (บน SO/SI ใน single SPI mode), 2 bits ในแต่ละครั้ง (บน IO0/IO1 ใน dual SPI mode), หรือ 4 bits ในแต่ละครั้ง (บน IO0/IO1/IO2/IO3 ใน quad SPI mode). นี้สามารถถูกกำหนดค่าโดยใช้ the ABMODE[1:0] field ของ QUADSPI_CCR[15:14] register.

เมื่อ DMODE = 00, the data phase จะถูกข้าม, และ the command sequence เสร็จสิ้นโดยทันทีโดยการพุ่งขึ้นของ nCS. การกำหนดค่านี้ต้องถูกใช้เฉพาะใน indirect write mode เท่านั้น.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 08:52:18 AM
14.3.4 QUADSPI signal interface protocol modes

Single SPI mode

Legacy SPI mode ยอมให้เพียง a single bit ถูกส่ง/ถูกรับแบบอนุกรม. ในโหมดนี้, data จะถูกส่งไปยัง the Flash memory บน the SO signal (ซึ่ง I/O แชร์กันกับ IO0). Data ที่รับจาก the Flash memory มาถึงโดยทาง SI (ซึ่ง I/O แชร์กันกับ IO1).

เฟสต่างๆแต่ละเฟสสามารถถูกกำหนดค่าแยกกันเพื่อใช้ single bit mode นี้โดยการเซ็ต the IMODE/ADMODE/ABMODE/DMODE fields (ใน QUADSPI_CCR) เป็น 01.

ในแต่ละ phase ซึ่งถูกกำหนดค่าใน single mode:
•   IO0 (SO) อยู่ใน output mode
•   IO1 (SI) อยู่ใน input mode (high impedance)
•   IO2 อยู่ใน output mode และถูกบังคับเป็น '0' (เพื่อทำให้ไม่ทำงาน the "write protect" function)
•   IO3 is in output mode และถูกบังคับเป็น '1' (เพื่อทำให้ไม่ทำงาน the "hold" function)

นี้เป็นกรณีแม้แต่สำหรับ the dummy phase ถ้า DMODE = 01.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 09:18:26 AM
Dual SPI mode

ใน dual SPI mode, two bits ถูกส่ง/ถูกรับพร้อมกันบน the IO0/IO1 signals.

เฟสต่างๆแต่ละเฟสสามารถถูกกำหนดค่าแยกกันเพื่อใช้ dual SPI mode โดยการเซ็ต the IMODE/ADMODE/ABMODE/DMODE fields of QUADSPI_CCR register เป็น 10.

ในแต่ละ phase ซึ่งถูกกำหนดค่าใน dual mode:
•   IO0/IO1 อยู่ที่ high-impedance (input) ในระหว่าง the data phase สำหรับ read operations, และเป็น outputs ในกรณีอื่น
     ทั้งหมด
•   IO2 อยู่ใน output mode และถูกบังคับเป็น '0'
•   IO3 อยู่ใน output mode และถูกบังคับเป็น '1'

ใน the dummy phase เมื่อ DMODE = 01, IO0/IO1 เป็น high-impedance เสมอ
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 09:32:50 AM
Quad SPI mode

ใน quad SPI mode, four bits ถูกส่ง/ถูกรับพร้อมกันบน the IO0/IO1/IO2/IO3 signals.

เฟสต่างๆแต่ละเฟสสามารถถูกกำหนดค่าแยกกันเพื่อใช้ quad SPI mode โดยการเซ็ต the IMODE/ADMODE/ABMODE/DMODE fields of QUADSPI_CCR register เป็น 11.

ในแต่ละ phase ซึ่งถูกกำหนดค่าใน quad mode, IO0/IO1/IO2/IO3 จะอยู่ที่ high-impedance ทั้งหมด (input) ในระหว่าง the data phase สำหรับ read operations, และเป็น outputs ในกรณีอื่นทั้งหมด.

ใน the dummy phase เมื่อ DMODE = 11, IO0/IO1/IO2/IO3 จะเป็น high-impedance ทั้งหมด.

IO2 and IO3 ถูกใช้เฉพาะใน Quad SPI mode. ถ้าไม่มี the phases ใดถูกกำหนดค่าเพื่อใช้ Quad SPI mode, ดังนั้น the pins ที่ตรงกันกับ IO2 and IO3 สามารถถูกใช้สำหรับฟังชั่นอื่นแม้แต่ในขณะที่ QUADSPI แอคทีฟ.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 09:54:33 AM
SDR mode

โดยค่าเริ่มต้น, the DDRM bit (QUADSPI_CCR[31]) เป็น 0 และ the QUADSPI ทำงานใน single data rate (SDR) mode.

ใน SDR mode, เมื่อ the QUADSPI กำลังขับ the IO0/SO, IO1, IO2, IO3 signals, การเปลี่ยนสัญญาณเหล่านี้จะเฉพาะกับขอบขาลงของ CLK.

เมื่อรับ data ใน SDR mode, the QUADSPI ทึกทักเอาว่า the Flash memories ส่ง the data โดยใช้ CLK's falling edge ด้วย. โดยค่าเริ่มต้น (เมื่อ SSHIFT = 0), the signals ถูกสุ่มโดยใช้ขอบที่ตามมา(ขอบขาขึ้น) ของ CLK.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 10:23:51 AM
DDR mode

เมื่อ the DDRM bit (QUADSPI_CCR[31]) ถูกเซ็ตเป็น 1, the QUADSPI จะทำงานใน double data rate (DDR) mode.

ใน DDR mode, เมื่อ the QUADSPI กำลังขับ the IO0/SO, IO1, IO2, IO3 signals ใน the address/alternate-byte/data phases, a bit จะถูกส่งบนแต่ละของ the falling and rising edges ของ CLK.

The instruction phase ไม่ได้รับผลกระทบโดย DDRM. The instruction จะถูกส่งโดยใช้ CLK's falling edge เสมอ.

เมื่อรับ data ใน DDR mode, the QUADSPI ทึกทักเอาว่า the Flash memories ส่ง the data โดยใช้ทั้ง rising and falling CLK edges ด้วย. เมื่อ DDRM = 1, firmware ต้องเคลียร์ SSHIFT bit (bit 4 of QUADSPI_CR). ดังนั้น, the signals จะถูกสุ่มที่ครึ่งหนึ่งของ a CLK cycle ต่อมา (บนขอบที่ตามมา, ขอบที่ตรงกันข้าม).

(https://i.imgur.com/iyQLYan.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 11:16:27 AM
Dual-flash mode

เมื่อ the DFM bit (bit 6 of QUADSPI_CR) เป็น 1, the QUADSPI จะอยู่ใน dual-flash mode, โดยที่ two external quad SPI Flash memories (FLASH 1 and FLASH 2) ถูกใช้เพื่อส่ง/รับ 8 bits (หรือ 16 bits ใน DDR mode) ทุก cycle, เพิ่ม the throughput เป็นสองเท่าอย่างมีประสิทธิภาพเช่นเดียวกันกับ the capacity.

แต่ละของ the Flash memories ใช้ the same CLK และมีทางเลือกใช้ the same nCS signals, แต่แต่ละมี IO0, IO1, IO2, and IO3 signals แยกกัน.

Dual-flash mode สามารถถูกใช้ร่วมกันกับ single-bit, dual-bit, and quad-bit modes, เช่นเดียวกันกับร่วมกันกับ SDR หรือ DDR mode อย่างใดอย่างหนึ่ง.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 11:32:22 AM
The Flash memory size, ตามที่ระบุใน FSIZE[4:0] (QUADSPI_DCR[20:16]), ควรสะท้อนถึง the total Flash memory capacity, ซึ่งเป็นสองเท่าขนาดของ one individual component.

ถ้า address X เป็นเลขคู่, ดังนั้น the byte ซึ่ง the QUADSPI ให้สำหรับ address X คือ the byte ที่ the address X/2 ของ FLASH 1, และ the byte ซึ่ง the QUADSPI ให้สำหรับ address X+1 คือ the byte ที่ the address X/2 ของ FLASH 2. กล่าวคือ, bytes ที่ even addresses ทั้งหมดถูกเก็บใน FLASH 1 และ bytes ที่ odd addresses ทั้งหมดถูกเก็บใน FLASH 2.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 11:52:39 AM
เมื่ออ่าน the Flash memories status registers ใน dual-flash mode, จะมีจำนวนไบต์เป็นสองเท่าถูกอ่านเมื่อเปรียบเทียบกับการอ่านแบบเดียวกันใน single-flash mode. นี้หมายความว่าถ้าแต่ละ Flash memory ให้ 8 valid bits หลังจาก the instruction สำหรับการดึง the status register, ดังนั้น the QUADSPI ต้องถูกกำหนดค่าด้วย a data length of 2 bytes (16 bits), และ the QUADSPI จะรับ one byte จากแต่ละ Flash memory. ถ้าแต่ละ Flash memory ให้ a status of 16 bits, ดังนั้น the QUADSPI ต้องถูกกำหนดค่าเพื่ออ่าน 4 bytes เพื่อให้ได้ทุก the status bits ของทั้งสอง Flash memories ใน dual-flash mode.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 24, 2022, 12:57:32 PM
จำนวนเลขคู่ของ bytes ต้องถูกเข้าถึงเสมอใน dual-flash mode. ด้วยเหตุผลนี้, bit 0 ของ the data length field (QUADSPI_DLR[0]) จะติดอยู่ที่ 1 เมื่อ DRM = 1.

ใน dual-flash mode, ลักษณะการทำงานของ FLASH 1 interface signals โดยพื้นฐานแล้วจะเหมือนกับใน normal mode. FLASH 2 interface signals มีรูปคลื่นเหมือนกับ  FLASH 1 ทุกประการในระหว่าง the instruction, address, alternate-byte, and dummy-cycles phases. กล่าวอีกนัยหนึ่ง, แต่ละ Flash memory รับ the same instruction and the same address เสมอ. จากนั้น, ในระหว่าง the data phase, the BK1_IOx and BK2_IOx buses ทั้งคู่จะส่งถ่าย data ขนานกัน, แต่ the data ที่ถูกส่งไปยัง (หรือถูกรับจาก) FLASH 1 จะแตกต่างจากเหล่านั้นของ FLASH 2.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 25, 2022, 08:37:00 AM
14.3.5 QUADSPI indirect mode

เมื่ออยู่ใน indirect mode, commands ถูกสตาร์ทโดยการเขียนไปยัง QUADSPI registers และ data ถูกส่งถ่ายโดยการเขียนหรือการอ่าน the data register, ในลักษณะเดียวกับสำหรับ communication peripherals อื่นๆ.

เมื่อ FMODE = 00 (QUADSPI_CCR[27:26]), the QUADSPI จะอยู่ใน indirect write mode, โดยที่ bytes จะถูกส่งไปยัง the Flash memory ในระหว่าง the data phase. Data ถูกจัดให้มีโดยการเขียนไปยัง the data register (QUADSPI_DR).

เมื่อ FMODE = 01, the QUADSPI จะอยู่ใน indirect read mode, โดยที่ bytes จะถูกรับจาก the Flash memory ในระหว่าง the data phase. Data จะถูกกู้โดยการอ่าน QUADSPI_DR.

จำนวนของ bytes ที่จะถูกอ่าน/เขียนถูกระบุใน the data length register (QUADSPI_DLR). ถ้า QUADSPI_DLR = 0xFFFF_FFFF (ทั้งหมดเป็น 1's), ดังนั้น the data length จะถูกพิจารณาว่าไม่ได้กำหนดและ the QUADSPI จะต่อเนื่องส่งถ่าย data ไปจนกว่า the end of Flash memory (ตามที่กำหนดโดย FSIZE) ถูกถึง. ถ้าไม่มี bytes ที่จะถูกส่งถ่าย, DMODE (QUADSPI_CCR[25:24]) ควรถูกเซ็ตเป็น 00.

ถ้า QUADSPI_DLR = 0xFFFF_FFFF and FSIZE = 0x1F (ค่าสูงสุดที่ระบุ a 4GB Flash memory), ดังนั้นในกรณีพิเศษนี้ the transfers จะต่อเนื่องไปอย่างไม่จำกัด, จะหยุดเฉพาะหลังจาก an abort request หรือหลังจาก the QUADSPI ถูกปิดใช้งาน. หลังจาก the last memory address ถูกอ่าน (ที่ address 0xFFFF_FFFF), การอ่านจะต่อเนื่องด้วย address = 0x0000_0000.

เมื่อจำนวนที่โปรแกรมของ bytes ที่จะถูกส่งหรือรับถูกถึง, TCF จะถูกเซ็ตและ an interrupt จะถูกสร้างถ้า TCIE = 1. ในกรณีที่ไม่ได้กำหนดจำนวนของ data, the TCF จะถูกเซ็ตเมื่อขีดจำกัดของ the external SPI memory ถูกถึงตาม the Flash memory size ที่กำหนดใน the QUADSPI_CR.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 25, 2022, 10:23:11 AM
Triggering the start of a command

โดยพื้นฐานแล้ว, a command จะสตาร์ททันทีที่ firmware ให้ the last information ที่จำเป็นสำหรับ command นี้. ขึ้นอยู่กับ the QUADSPI configuration, มีสามวิธีที่แตกต่างกันในการทริก the start of a command ใน indirect mode. The commands จะสตาร์ททันทีหลังจาก:
1.   การเขียนถูกดำเนินการไปยัง INSTRUCTION[7:0] (QUADSPI_CCR), ถ้า address ไม่มีความจำเป็น (เมื่อ ADMODE = 00) และ
      ถ้าไม่มี data จำเป็นต้องถูกจัดให้มีโดย the firmware (เมื่อ FMODE = 01 or DMODE = 00)
2.   การเขียนถูกดำเนินการไปยัง ADDRESS[31:0] (QUADSPI_AR), ถ้า an address มีความจำเป็น (เมื่อ ADMODE != 00) และถ้า
      ไม่มี data จำเป็นต้องถูกจัดให้มีโดย the firmware (เมื่อ FMODE = 01 or DMODE = 00)
3.   การเขียนถูกดำเนินการไปยัง DATA[31:0] (QUADSPI_DR), ถ้า an address มีความจำเป็น  (เมื่อ ADMODE != 00) และถ้า
      data จำเป็นต้องถูกจัดให้มีโดย the firmware (เมื่อ FMODE = 00 and DMODE != 00)

การเขียนไปยัง the alternate byte register (QUADSPI_ABR) จะไม่ทริก the communication start. ถ้า bytes สำรองถูกต้องการ, พวกมันต้องถูกโปรแกรมไว้ก่อน.

ทันทีที่ a command ถูกสตาร์ท, the BUSY bit (bit 5 of QUADSPI_SR) จะถูกเซ็ตโดยอัตโนมัติ.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 25, 2022, 10:34:59 AM
FIFO and data management

ใน indirect mode, data จะผ่าน a 32-byte FIFO ซึ่งอยู่ภายใน the QUADSPI. FLEVEL[5:0] (QUADSPI_SR[13:8]) แสดงให้เห็น bytes จำนวนเท่าไหร่ที่ตอนนี้กำลังถูกถือไว้ใน the FIFO.

ใน indirect write mode (FMODE = 00), firmware เพิ่ม data ไปยัง the FIFO เมื่อมันเขียน QUADSPI_DR. Word writes เพิ่ม 4 bytes ไปยัง the FIFO, halfword writes เพิ่ม 2 bytes, และ byte writes เพิ่มเฉพาะ 1 byte. ถ้า firmware เพิ่ม bytes มากเกินไปไปยัง the FIFO (มากกว่าที่แสดงให้เห็นโดย DL[31:0]), the bytes ที่เกินจะถูกล้างจาก the FIFO ที่ the end of the write operation (เมื่อ TCF ถูกเซ็ต).

Byte/halfword เข้าถึงไปยัง QUADSPI_DR ต้องถูกทำเฉพาะกับ the least significant byte/halfword ของ the 32-bit register.

FTHRES[3:0] ถูกใช้เพื่อกำหนด a FIFO threshold. เมื่อขอบเขตถูกถึง, the FTF (FIFO threshold flag) จะถูกเซ็ต. ใน indirect read mode, FTF จะถูกเซ็ตเมื่อจำนวนของ valid bytes ที่จะถูกอ่านจาก the FIFO อยู่เหนือขอบเขต. FTF จะถูกเซ็ตด้วยถ้ามี data ใน the FIFO หลังจาก the last byte ถูกอ่านจากthe Flash memory, โดยไม่คำนึงถึง the FTHRES setting. ใน indirect write mode, FTF จะถูกเซ็ตเมื่อจำนวนของ empty bytes ใน the FIFO อยุ่เหนือขอบเขต.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 25, 2022, 11:10:55 AM
ถ้า FTIE = 1, จะมี an interrupt เมื่อ FTF ถูกเซ็ต. ถ้า DMAEN = 1, a DMA transfer จะถูกเริ่มต้นเมื่อ FTF ถูกเซ็ต. FTF จะถูกเคลียร์โดย HW ทันทีที่ the threshold ไม่เป็นจริงอีกต่อไป (หลังจาก enough data ถูกส่งถ่ายแล้วโดย the CPU or DMA).

ใน indirect read mode, เมื่อ the FIFO กลายมาเป็นเต็ม, the QUADSPI จะหยุดชั่วคราวการอ่าน bytes จาก the Flash memory เพื่อหลีกเลี่ยง an overrun. บันทึกไว้ว่าการอ่านของ the Flash memory จะไม่รีสตาร์ทจนกว่า 4 bytes จะว่างใน the FIFO (เมื่อ FLEVEL ≤ 28). ดังนั้น เมื่อ FTHRES ≥ 29 แอปพลิเคชันจะต้องดูแลเพื่ออ่านจำนวนไบต์ให้เพียงพอเพื่อให้แน่ใจว่า the QUADSPI จะสตาร์ทการดึง data จาก the Flash memory อีกครั้ง. มิฉะนั้น, the FTF flag จะอยู่ที่ '0' ตราบใดที่ 28 < FLEVEL < FTHRES.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 25, 2022, 02:45:03 PM
14.3.6 QUADSPI status flag polling mode

ใน automatic-polling mode, the QUADSPI จะสตาร์ท a command เป็นระยะเพื่ออ่านจำนวนที่กำหนดไว้ของ status bytes (มากถึง 4). The received bytes สามารถถูกบังเพื่อแยกบาง status bits และ an interrupt สามารถถูกสร้างเมื่อบิตที่เลือกมีค่าที่กำหนด.

การเข้าถึงไปยัง the Flash memory จะเริ่มในลักษณะเดียวกับใน indirect read mode: ถ้าไม่มี address ถูกต้องการ (AMODE = 00), การเข้าถึงจะเริ่มทันทีที่ the QUADSPI_CCR ถูกเขียน. มิฉะนั้น, ถ้า an address ถูกต้องการ, the first access จะเริ่มเมื่อ QUADSPI_AR ถูกเขียน. BUSY ไปเป็น high ณ จุดนี้และคงอยู่ high แม้ระหว่างการเข้าถึงเป็นระยะๆ.

สิ่งที่บรรจุอยู่ภายในของ MASK[31:0] (QUADSPI_PSMAR) ถูกใช้เพื่อบัง the data จาก the Flash memory ใน automatic-polling mode. ถ้า the MASK[n] = 0, ดังนั้น bit n ของ the result จะถูกบังและไม่ถูกพิจารณา. ถ้า MASK[n] = 1, และสิ่งที่บรรจุอยู่ภายในของ bit[n] เป็นอย่างเดียวกันกับ MATCH[n] (QUADSPI_PSMAR), ดังนั้นมีคู่ที่เหมือนกันสำหรับ bit n.

ถ้า the polling match mode bit (PMM, bit 23 of QUADSPI_CR) เป็น 0, ดังนั้น "AND" match mode ถูกทำให้ทำงาน. นี้หมายความว่า status match flag (SMF) จะถูกเซ็ตเฉพาะเมื่อมีคู่ที่เหมือนกันบนทั้งหมดของ the unmasked bits.

ถ้า PMM = 1, ดังนั้น "OR" match mode ถูกทำให้ทำงาน. นี้หมายความว่า SMF จะถูกเซ็ตถ้ามีคู่ที่เหมือนกันบนบิตใดๆของ the unmasked bits.

An interrupt จะถูกเรียกเมื่อ SMF ถูกเซ็ตถ้า SMIE = 1.

ถ้า the automatic-polling-mode-stop (APMS) bit ถูกเซ็ต, การทำงานจะหยุดลงและ BUSY จะกลายเป็น 0 ทันทีที่มีคู่ที่เหมือนกันถูกตรวจพบ. มิฉะนั้น, BUSY จะอยู่ที่ '1' และการเข้าถึงเป็นระยะดำเนินการต่อไปจนกว่าจะมีการยกเลิกหรือ the QUADSPI ถูกปิดใช้งาน (EN = 0).

The data register (QUADSPI_DR) บรรจุ the latest received status bytes (the FIFO ถูกทำให้ไม่ทำงาน). สิ่งที่บรรจุอยู่ภายในของ the data register ไม่ได้รับผลกระทบโดยการบังที่ใช้ใน the matching logic. The FTF status bit จะถูกเซ็ตทันทีที่ a new reading ของ the status เสร็จสิ้น, และ FTF จะถูกเคลียร์ทันทีที่ the data ถูกอ่าน.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 08:35:20 AM
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 ถูกปิดใช้งาน.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 09:32:02 AM
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).
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 10:22:41 AM
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 ถูกเซ็ต.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 01:37:15 PM
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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 02:20:47 PM
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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 02:30:32 PM
เมื่อเขียน 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
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 03:00:37 PM
เมื่อเขียน 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
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 03:26:45 PM
ถ้าไม่ทั้ง 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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 05:29:55 PM
Status flag polling mode

The status flag polling mode ถูกเปิดใช้งานโดยการเซ็ต the FMODE field (QUADSPI_CCR[27:26]) เป็น 10. ในโหมดนี้, the programmed frame จะถูกส่งและ the data จะถูกดึงเป็นระยะๆ.

จำนวนสูงสุดของ data ที่อ่านในแต่ละ frame คือ 4 bytes. ถ้า data ที่มากกว่านี้ถูกร้องขอใน QUADSPI_DLR, มันจะถูดเพิกเฉยและเฉพาะ 4 bytes จะถูกอ่าน.

The periodicity ถูกระบุใน the QUADSPI_PISR register.

ทันทีที่ the status data ถูกดึงแล้ว, มันสามารถถูกประมวลผลภายในเพื่อ:
•   เซ็ต the status match flag และสร้าง an interrupt ถ้าถูกเปิดใช้งาน
•   หยุดโดยอัตโนมัติการดึงเป็นระยะๆของ the status bytes

The received value สามรถถูกบังด้วย the value ที่เก็บใน the QUADSPI_PSMKR และถูก OR หรือถูก AND ด้วย the value ที่เก็บใน the QUADSPI_PSMAR.

ในกรณีของคู่ที่เหมือนกัน, the status match flag จะถูกเซ็ตและ an interrupt จะถูกสร้างถ้าเปิดใช้งาน, และ the QUADSPI สามารถถูกหยุดโดยอัตโนมัติถ้า the AMPS bit ถูกเซ็ต.

ในกรณีใดๆ, the latest retrieved value จะมีให้ใช้ประโยชน์ใน the QUADSPI_DR.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 26, 2022, 05:41:43 PM
Memory-mapped mode

ใน memory-mapped mode, the external Flash memory จะถูกมองเป็น internal memory แต่มีเวลาแฝงในระหว่าง accesses. เฉพาะ read operations ถูกอนุญาตให้กับ the external Flash memory ในโหมดนี้.

Memory-mapped mode ถูกเข้าสู่โดยการเซ็ต the FMODE เป็น 11 ใน the QUADSPI_CCR register.

The programmed instruction และ frame จะถูกส่งเมื่อ a master กำลังเข้าถึง the memory mapped space.

The FIFO ถูกใช้เป็น a prefetch buffer เพื่อคาดการณ์ linear reads. การเข้าถึงใดๆไปยัง QUADSPI_DR ในโหมดนี้จะส่งคืนกลับศูนย์.

The data length register (QUADSPI_DLR) ไม่มีความหมายใน memory-mapped mode.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 07:54:31 AM
14.3.12 Sending the instruction only once

บาง Flash memories (อย่างเช่น Winbound) อาจจัดให้มี a mode โดยที่ an instruction ต้องถูกส่งเฉพาะกับ the first command sequence, ในขณะที่ subsequent commands สตาร์ทโดยตรงกับ the address. เราสามารถใช้ประโยชน์จากคุณสมบัติดังกล่าวได้โดยใช้ the SIOO bit (QUADSPI_CCR[28]).

SIOO ใช้ได้สำหรับทุก functional modes (indirect, automatic polling, and memory-mapped). ถ้า the SIOO bit ถูกเซ็ต, the instruction จะถูกส่งเฉพาะสำหรับ the first command ที่ตาม a write ไปยัง QUADSPI_CCR. Subsequent command sequences จะข้าม the instruction phase, จนกว่าจะมีเขียนถึง QUADSPI_CCR.

SIOO จะไม่มีผลอะไรเมื่อ IMODE = 00 (ไม่มี instruction).
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 09:37:17 AM
14.3.13 QUADSPI error management

An error สามารถถูกสร้างในกรณีต่อไปนี้:
•   ใน indirect mode หรือ status flag polling mode เมื่อ a wrong address ถูกโปรแกรมแล้วใน the QUADSPI_AR (สอดคล้อง
     กับ the Flash memory size ที่กำหนดโดย FSIZE[4:0] ใน the QUADSPI_DCR): นี้จะเซ็ต the TEF และ an interrupt จะถูก
     สร้างถ้าถูกเปิดใช้งาน.
•   นอกจากนี้ใน indirect mode, ถ้า the address บวกกับ the data length เกิน the Flash memory size, TEF จะถูกเซ็ตทันทีที่
     the access ถูกทริก.
•   ใน memory-mapped mode, เมื่อการเข้าถึงนอกย่านถูกทำโดย a master หรือเมื่อ the QUADSPI ถูกปิดใช้งาน: นี้จะสร้าง a bus
     error เป็นการตอบสนองต่อ the faulty bus master request.
•   เมื่อ a master กำลังเข้าถึง the memory mapped space ในขณะที่ the memory mapped mode ถูกปิดใช้งาน: นี้จะสร้าง a
     bus error เป็นการตอบสนองต่อ the faulty bus master request.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 09:52:43 AM
14.3.14 QUADSPI busy bit and abort functionality

ทันทีที่ the QUADSPI สตาร์ท an operation กับ the Flash memory, the BUSY bit จะถูกเซ็ตโดยอัตโนมัติใน the QUADSPI_SR.

ใน indirect mode, the BUSY bit จะถูกรีเซ็ตทันทีที่ the QUADSPI ได้เสร็จสิ้น the requested command sequence และ the FIFO ว่างเปล่า.

ใน automatic-polling mode, BUSY ไปเป็น low เฉพาะหลังจาก the last periodic access เสร็จสมบูรณ์, เนื่องจาก a match(คู่ที่เหมือนกัน) เมื่อ APMS = 1, หรือเนื่องจาก an abort.

หลังจาก the first access ใน memory-mapped mode, BUSY ไปเป็น low เฉพาะบน a timeout event หรือบน an abort.

operation ใดๆสามารถถูกยกเลิกได้โดยการเซ็ต the ABORT bit ใน the QUADSPI_CR. ทันทีที่ the abort เสร็จสมบูรณ์, the BUSY bit and the ABORT bit จะถูกรีเซ็ตโดยอัตโนมัติ, and the FIFO จะถูกล้าง.

Note:  บาง Flash memories อาจทำงานผิดปกติถ้า a write operation ไปยัง a status registers ถูกยกเลิก.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 10:20:47 AM
14.3.15 nCS behavior

โดยค่าเริ่มต้น, nCS เป็น high, จะถอนการเลือก the external Flash memory. nCS จะตกก่อนการทำงานเริ่มและจะพุ่งขึ้นทันทีที่มันเสร็จงาน.

เมื่อ CKMODE = 0 ("mode0", โดยที่ CLK อยู่ low เมื่อไม่มี operation กำลังดำเนินการอยู่) nCS จะตก one CLK cycle ก่อน an operation first rising CLK edge, และ nCS จะพุ่งขึ้น one CLK cycle หลังจาก the operation final rising CLK edge, ดังแสดงใน Figure 66.

(https://i.imgur.com/jSzFTHz.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 10:30:22 AM
เมื่อ CKMODE=1 ("mode3", โดยที่ CLK ไปเป็น high เมื่อไม่มี operation กำลังดำเนินการอยู่) และ DDRM=0 (SDR mode), nCS ยังคงตก one CLK cycle ก่อน an operation first rising CLK edge, และ nCS จะพุ่งขึ้น one CLK cycle หลังจาก the operation final rising CLK edge, ดังแสดงใน Figure 67.

(https://i.imgur.com/ExemjSm.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 10:42:34 AM
เมื่อ CKMODE = 1 ("mode3") และ DDRM = 1 (DDR mode), nCS จะตก one CLK cycle ก่อน an operation first rising CLK edge, และ nCS จะพุ่งขึ้น one CLK cycle หลังจาก the operation final active rising CLK edge, ดังแสดงใน Figure 68. เนื่องจาก DDR operations ต้องเสร็จงานด้วย a falling edge, CLK จะเป็น low เมื่อ nCS พุ่งขึ้น, and CLK จะพุ่งขึ้นค้ำชูครึ่งหนึ่งของ a CLK cycle หลังจากนั้น.

(https://i.imgur.com/b3dOPY4.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 11:01:56 AM
เมื่อ 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.

(https://i.imgur.com/SUoboht.png)

เมื่อไม่อยู่ใน 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 สามารถถูกใช้สำหรับฟังชั่นอื่น.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 11:13:07 AM
14.4 QUADSPI interrupts

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

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

(https://i.imgur.com/9inxTiz.png)
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 02:16:41 PM
14.5 QUADSPI registers

14.5.1 QUADSPI control register (QUADSPI_CR)

Address offset: 0x0000
Reset value: 0x0000 0000

(https://i.imgur.com/Qxu8OY0.png)

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 ถูกเปิดใช้งาน
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 03:28:25 PM
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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 27, 2022, 04:22:22 PM
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 ถูกเปิดใช้งาน
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 07:04:39 AM
14.5.2 QUADSPI device configuration register (QUADSPI_DCR)

Address offset: 0x0004
Reset value: 0x0000 0000

(https://i.imgur.com/3VJPzLu.png)

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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 08:00:52 AM
14.5.3 QUADSPI status register (QUADSPI_SR)

Address offset: 0x0008
Reset value: 0x0000 0000

(https://i.imgur.com/8tixwM5.png)

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.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 08:26:31 AM
14.5.4 QUADSPI flag clear register (QUADSPI_FCR)

Address offset: 0x000C
Reset value: 0x0000 0000

(https://i.imgur.com/MWvxzDT.png)

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
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 09:06:59 AM
14.5.5 QUADSPI data length register (QUADSPI_DLR)

Address offset: 0x0010
Reset value: 0x0000 0000

(https://i.imgur.com/iX5uNkF.png)

Bits 31:0 DL[31:0]: Data length
     จำนวนของ data ที่จะถูกดึง (value+1) ใน indirect and status-polling modes. A value ไม่เกิน 3 (แสดง 4 bytes) ควรถูกใช้
     สำหรับ status-polling mode.
     เป็น 1s ทั้งหมดใน indirect mode หมายถึงความยาวที่ไม่ได้กำหนด, โดยที่ QUADSPI จะต่อเนื่องเรื่อยไปจนกว่า the end of
     memory, ตามที่กำหนดโดย FSIZE.
     0x0000_0000: 1 byte ที่จะถูกส่งถ่าย
     0x0000_0001: 2 bytes ที่จะถูกส่งถ่าย
     0x0000_0002: 3 bytes ที่จะถูกส่งถ่าย
     0x0000_0003: 4 bytes ที่จะถูกส่งถ่าย
     ...
     0xFFFF_FFFD: 4,294,967,294 (4G-2) bytes ที่จะถูกส่งถ่าย
     0xFFFF_FFFE: 4,294,967,295 (4G-1) bytes ที่จะถูกส่งถ่าย
     0xFFFF_FFFF: ความยาวที่ไม่ได้กำหนด -- ทุก bytes จนกว่า the end of Flash memory (ตามที่กำหนดโดย FSIZE) จะถูกส่ง
     ถ่าย. การอ่านอย่างต่อเนื่องไม่มีที่สิ้นสุดถ้า FSIZE = 0x1F.
     DL[0] จะถูกติดอยู่ที่ '1' ใน dual-flash mode (DFM = 1) แม้ว่าเมื่อ '0' ถูกเขียนไปยังบิตนี้, ดังนั้นทำให้มั่นใจได้ว่าแต่ละ access จะ
     ส่งถ่ายจำนวนไบต์เป็นเลขคู่.
     ฟิลด์นี้จะไม่มีผลอะไรเมื่ออยู่ใน memory-mapped mode (FMODE = 10).
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 10:56:48 AM
14.5.6 QUADSPI communication configuration register (QUADSPI_CCR)

Address offset: 0x0014
Reset value: 0x0000 0000

(https://i.imgur.com/ADXcw0E.png)

Bit 31 DDRM: Double data rate mode
     บิตนี้เซ็ต the DDR mode สำหรับ the address, alternate byte และ data phase:
     0: DDR Mode ถูกปิดใช้งาน
     1: DDR Mode ถูกเปิดใช้งาน
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bit 30 DHHC: DDR hold
     หน่วงเวลา the data output ล่วงไป 1/4 of the QUADSPI output clock cycle ใน DDR mode:
     0: หน่วงเวลา the data output โดยใช้ analog delay
     1: หน่วงเวลา the data output ล่วงไป 1/4 of a QUADSPI output clock cycle.
     คุณลักษณะแอคทีฟเฉพาะใน DDR mode.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bit 29 Reserved, must be kept at reset value.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 11:14:50 AM
Bit 28 SIOO: Send instruction only once mode
     ดู Section 14.3.12: Sending the instruction only once on page 396. บิตนี้จะไม่มีผลอะไรเมื่อ IMODE = 00.
     0: ส่ง instruction บนทุกๆ transaction
     1: ส่ง instruction เฉพาะสำหรับ the first command
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 27:26 FMODE[1:0]: Functional mode
     ฟิลด์นี้กำหนด the QUADSPI functional mode of operation.
     00: Indirect write mode
     01: Indirect read mode
     10: Automatic polling mode
     11: Memory-mapped mode
     ถ้า DMAEN = 1 แล้ว, ดังนั้น the DMA controller สำหรับ the corresponding channel ต้องถูกปิดใช้งานก่อนการเปลี่ยน the
     FMODE value.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 25:24 DMODE[1:0]: Data mode
     ฟิลด์นี้กำหนด the data phase's mode of operation:
     00: No data
     01: Data on a single line
     10: Data on two lines
     11: Data on four lines
     ฟิลด์นี้กำหนด the dummy phase mode of operation อีกด้วย.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bit 23 Reserved, must be kept at reset value.

Bits 22:18 DCYC[4:0]: Number of dummy cycles
     ฟิลด์นี้กำหนดช่วงเวลาของ the dummy phase. ในทั้ง SDR and DDR modes, มันระบุจำนวนของ CLK cycles (0-31).
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 17:16 ABSIZE[1:0]: Alternate bytes size
     ฟิลด์นี้กำหนด alternate bytes size:
     00: 8-bit alternate byte
     01: 16-bit alternate bytes
     10: 24-bit alternate bytes
     11: 32-bit alternate bytes
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 15:14 ABMODE[1:0]: Alternate bytes mode
     ฟิลด์นี้กำหนด the alternate-bytes phase mode of operation:
     00: No alternate bytes
     01: Alternate bytes on a single line
     10: Alternate bytes on two lines
     11: Alternate bytes on four lines
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 11:24:53 AM
Bits 13:12 ADSIZE[1:0]: Address size
     บิตนี้กำหนด address size:
     00: 8-bit address
     01: 16-bit address
     10: 24-bit address
     11: 32-bit address
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 11:10 ADMODE[1:0]: Address mode
     ฟิลด์นี้กำหนด the address phase mode of operation:
     00: No address
     01: Address on a single line
     10: Address on two lines
     11: Address on four lines
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 9:8 IMODE[1:0]: Instruction mode
     ฟิลด์นี้กำหนด the instruction phase mode of operation:
     00: No instruction
     01: Instruction on a single line
     10: Instruction on two lines
     11: Instruction on four lines
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.

Bits 7:0 INSTRUCTION[7:0]: Instruction
     Instruction ที่จะถูกส่งไปยัง the external SPI device.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 12:04:13 PM
14.5.7 QUADSPI address register (QUADSPI_AR)

Address offset: 0x0018
Reset value: 0x0000 0000

(https://i.imgur.com/7Mh89CR.png)

Bits 31:0 ADDRESS[31:0]: Address
     Address ที่จะถูกส่งไปยัง the external Flash memory
     การเขียนถึงฟิลด์นี้จะถูกเพิกเฉยเมื่อ BUSY = 0 หรือเมื่อ FMODE = 11 (memory-mapped mode).
     ใน dual flash mode, ADDRESS[0] จะถูกติดที่ '0' โดยอัตโนมัติเนื่องจาก the address ควรเป็นเลขคู่เสมอ
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 12:15:54 PM
14.5.8 QUADSPI alternate bytes registers (QUADSPI_ABR)

Address offset: 0x001C
Reset value: 0x0000 0000

(https://i.imgur.com/YrIbUzq.png)

Bits 31:0 ALTERNATE[31:0]: Alternate Bytes
     data ทางเลือกที่จะถูกส่งไปยัง the external SPI device ทันทีหลังจาก the address.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 03:23:51 PM
14.5.9 QUADSPI data register (QUADSPI_DR)

Address offset: 0x0020
Reset value: 0x0000 0000

(https://i.imgur.com/ThwEoBq.png)

Bits 31:0 DATA[31:0]: Data
     Data ที่จะถูกส่ง/ถูกรับ ไปยัง/จาก the external SPI device.
     ใน indirect write mode, data ที่เขียนไปยัง register นี้จะถูกเก็บบน the FIFO ก่อนที่มันจะถูกส่งไปยัง the Flash memory ใน
     ระหว่าง the data phase. ถ้า the FIFO เต็มเกินไป, a write operation จะถูกหยุดจนกว่า the FIFO จะมีพื้นที่เพียงพที่จะรับจำนวน
     ของ data ที่กำลังถูกเขียน.
     ใน indirect read mode, การอ่าน register นี้จะให้ (โดยทาง the FIFO) the data ซึ่งถูกรับจาก the Flash memory. ถ้า the
     FIFO ไม่มีจำนวนไบต์ตามที่ร้องขอโดย the read operation และถ้า BUSY=1, the read operation จะถูกหยุดจนกว่า data ที่
     เพียงพอปรากฎหรือจนกว่า the transfer เสร็จสมบูรณ์, แล้วแต่กรณีใดจะเกิดขึ้นก่อน.
     ใน automatic polling mode, register นี้บรรจุ the last data ที่อ่านจาก the Flash memory (โดยไม่มีการบัง).
     Word, halfword, and byte accesses ไปยัง register นี้ถูกรองรับ. ใน indirect write mode, a byte write จะเพิ่ม 1 byte ไป
     ยัง the FIFO, a halfword write 2, และ a word write 4. ในทำนองเดียวกัน, ใน indirect read mode, a byte read จะลบ 1
     byte จาก the FIFO, a halfword read 2, และ a word read 4. การเข้าถึงใน indirect mode จะต้องถูกจัดแนวชิดด้านล่างของ
     register นี้: a byte read ต้องอ่าน DATA[7:0] และ a halfword read ต้องอ่าน DATA[15:0].
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 04:00:20 PM
14.5.10 QUADSPI polling status mask register (QUADSPI _PSMKR)

Address offset: 0x0024
Reset value: 0x0000 0000

(https://i.imgur.com/0p17EO2.png)

Bits 31:0 MASK[31:0]: Status mask
     Mask ถูกนำมาใช้กับ the status bytes ที่รับใน polling mode.
     สำหรับ bit n:
     0: Bit n of the data ที่รับใน automatic polling mode ถูกบังและค่าของมันไม่ถูกพิจารณาใน the matching logic
     1: Bit n of the data ที่รับใน automatic polling mode ไม่ถูกบังและค่าของมันถูกพิจารณาใน the matching logic
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 04:06:12 PM
14.5.11 QUADSPI polling status match register (QUADSPI _PSMAR)

Address offset: 0x0028
Reset value: 0x0000 0000

(https://i.imgur.com/cuULqRr.png)

Bits 31:0 MATCH[31:0]: Status match
     Value ถูกเปรียบเทียบกับ the masked status register เพื่อให้ได้ a match(คู่ที่เหมือนกัน).
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 04:12:37 PM
14.5.12 QUADSPI polling interval register (QUADSPI _PIR)

Address offset: 0x002C
Reset value: 0x0000 0000

(https://i.imgur.com/imyWwvR.png)

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

Bits 15:0 INTERVAL[15:0]: Polling interval
     จำนวนของ CLK cycles ระหว่างการอ่านในระหว่าง automatic polling phases.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 04:26:17 PM
14.5.13 QUADSPI low-power timeout register (QUADSPI_LPTR)

Address offset: 0x0030
Reset value: 0x0000 0000

(https://i.imgur.com/aw6IFSP.png)

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

Bits 15:0 TIMEOUT[15:0]: Timeout period
     หลังจากแต่ละ access ใน memory-mapped mode, the QUADSPI ดึงล่วงหน้า the subsequent bytes และถือ bytes เหล่านี้
     ใน the FIFO. ฟิลด์นี้ระบุ CLK cycles จำนวนเท่าใดที่ the QUADSPI รอหลังจากที่ the FIFO เต็มจนถึงมันพุ่งขึ้น nCS, แล้วจึงใส่
     the Flash memory ใน a lower-consumption state.
     ฟิลด์นี้สามารถถูกเขียนเฉพาะเมื่อ BUSY = 0.
Title: Re: STM32F7 14 Quad-SPI interface (QUADSPI)
Post by: tha on November 28, 2022, 04:30:28 PM
(https://i.imgur.com/uX1OQXN.png)
(https://i.imgur.com/SpfwbGG.png)