日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

《STM32从零开始学习历程》——SPI物理层及FLASH芯片介绍

發布時間:2024/1/1 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 《STM32从零开始学习历程》——SPI物理层及FLASH芯片介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

《STM32從零開始學習歷程》@EnzoReventon

SPI物理層及FLASH芯片介紹

相關鏈接:
SPI協議層
SPI特性及架構
SPI固件庫

參考資料:
[野火EmbedFire]《STM32庫開發實戰指南——基于野火霸天虎開發板》
[正點原子]STM32F4開發指南-庫函數版本_V1.2
[ST]《STM32F4xx中文參考手冊》
SPI協議及總線協議介紹
W25Q128產品數據手冊

SPI協議介紹

  • SPI 協議是由摩托羅拉公司提出的通訊協議(Serial Peripheral Interface),即串行外圍設備接口,是一種高速全雙工的通信總線。它被廣泛地使用在ADC、LCD 等設備與MCU 間,要求通訊速率較高的場合。

物理層介紹




SS: 從設備選擇信號線,常稱為片選信號線,也稱為NSS,CS。

  • 每個從設備都有獨立的這一條SS信號線,本信號線獨占主機的一個引腳,即有多少個從設備,就有多少條片選信號線。I2C協議中通過設備地址來尋址、選中總線上的某個設備并與其進行通訊;
  • 而SPI協議中沒有設備地址,它使用SS信號線來尋址,當主機要選擇從設備時,把該從設備的SS信號線設置為低電平,該從設備即被選中,即片選有效,接著主機開始與被選中的從設備進行SPI通訊。
  • 所以SPI通訊以SS線置低電平為開始信號,以SS線被拉高作為結束信號。

SCK: 時鐘信號線,用于通訊數據同步。

  • 它由通訊主機產生,決定了通訊的速率,不同的設備支持的最高時鐘頻率不一樣,如STM32的SPI時鐘頻率最大為fpclk/2(選APB1或APB2,最大為42MHz或者21MHz),兩個設備之間通訊時**,通訊速率受限于低速設備**。

MOSI:(Master Output,Slave Input) 主設備輸出/從設備輸入引腳。

  • 主機的數據從這條信號線輸出,從機由這條信號線讀入主機發送的數據,即這條線上數據的方向為主機到從機。

MISO:(Master Input,Slave Output) 主設備輸入/從設備輸出引腳。

  • 主機從這條信號線讀入數據,從機的數據由這條信號線輸出到主機,即在這條線上數據的方向為從機到主機。

WP:

  • 寫保護。低電平有效。

HOLD:

  • 暫停功能,處理比當前任務更重要的任務時,把當前任務暫停,保持當前狀態,先處理另一個任務。

W25Q128產品數據手冊解讀

W25Q128產品數據手冊

The W25Q128FV (128M-bit) Serial Flash memory provides a storage solution for systems with limited space, pins and power. The 25Q series offers flexibility and performance well beyond ordinary Serial Flash devices. They are ideal for code shadowing to RAM, executing code directly from Dual/Quad SPI (XIP) and storing voice, text and data. The device operates on a single 2.7V to 3.6V power supply with current consumption as low as 4mA active and 1μA for power-down. All devices are offered in space-saving packages.

W25Q128FV(128M位,16兆字節)串行閃存為空間、引腳和電源有限的系統提供存儲解決方案。25Q系列提供的靈活性和性能遠遠超過普通串行閃存設備。它們非常適合于將代碼存儲到RAM中,直接從雙/四SPI(XIP)執行代碼并存儲語音、文本和數據(NOR FLASH)。該裝置采用2.7V至3.6V的單電源供電,電流消耗低至4mA,斷電時為1μa。所有設備均采用節省空間的包裝。
ps:F407芯片內部有一個1MB的NOR FLASH用來存儲程序,且不支持將程序存儲到外部的NOR FLASH中。

The W25Q128FV array is organized into 65,536 programmable pages of 256-bytes each. Up to 256 bytes can be programmed at a time. Pages can be erased in groups of 16 (4KB sector erase), groups of 128 (32KB block erase), groups of 256 (64KB block erase) or the entire chip (chip erase). The W25Q128FV has 4,096 erasable sectors and 256 erasable blocks respectively. The small 4KB sectors allow for greater flexibility in applications that require data and parameter storage.

W25Q128FV陣列被組織成65536個可編程頁,每個頁256字節。一次最多可編程256字節。頁面可以按16組(4KB扇區擦除)、128組(32KB塊擦除)、256組(64KB塊擦除)或整個芯片(芯片擦除)擦除(可以按頁、字節寫入擦除的最小單位為扇區 4096字節)。W25Q128FV分別有4096個可擦除扇區和256個可擦除塊。小的4KB扇區允許在需要數據和參數存儲的應用程序中具有更大的靈活性。

The W25Q128FV support the standard Serial Peripheral Interface (SPI), Dual/Quad I/O SPI as well as 2-clocks instruction cycle Quad Peripheral Interface (QPI): Serial Clock, Chip Select, Serial Data I/O0 (DI), I/O1 (DO), I/O2 (/WP), and I/O3 (/HOLD). SPI clock frequencies of up to 104MHz are supported allowing equivalent clock rates of 208MHz (104MHz x 2) for Dual I/O and 416MHz (104MHz x 4) for Quad I/O when using the Fast Read Dual/Quad I/O and QPI instructions. These transfer rates can outperform standard Asynchronous 8 and 16-bit Parallel Flash memories. The Continuous Read Mode allows for efficient memory access with as few as 8-clocks of instruction-overhead to read a 24-bit address, allowing true XIP (execute in place) operation.

W25Q128FV 支持標準串行外圍接口(SPI)、雙/四I/O SPI 以及2時鐘指令循環四外圍接口(QPI):串行時鐘、芯片選擇、串行數據I/O0(DI)、I/O1(DO)、I/O2(/WP)和I/O3(/HOLD)。支持最多104MHz的SPI時鐘頻率,當使用快速讀取雙/四輸入/四輸入/輸出和QPI指令時,允許雙I/O的等效時鐘速率208MHz(104MHz x 2),四I/O的等效時鐘速率為416MHz(104MHz x 4)。這些傳輸速率可以優于標準的異步8位和16位并行閃存。連續讀取模式允許高效的內存訪問,只需8個時鐘的指令開銷,即可讀取24位地址,從而允許真正的XIP(就地執行)操作。

====================================================================================

STATUS AND CONFIGURATION REGISTERS
Three Status and Configuration Registers are provided for W25Q128FV. The Read Status Register-
1/2/3 instructions can be used to provide status on the availability of the flash memory array, whether
the device is write enabled or disabled, the state of write protection, Quad SPI setting, Security Register
lock status, Erase/Program Suspend status, output driver strength, power-up and current Address
Mode. The Write Status Register instruction can be used to configure the device write protection features,
Quad SPI setting, Security Register OTP locks, Hold/Reset functions, output driver strength and powerup
Address Mode. Write access to the Status Register is controlled by the state of the non-volatile Status
Register Protect bits (SRP0, SRP1), the Write Enable instruction, and during Standard/Dual SPI
operations, the /WP pin.

狀態和配置寄存器W25Q128FV提供三個狀態和配置寄存器。讀取狀態寄存器-1/2/3指令可用于提供閃存陣列可用性的狀態,無論該設備是寫啟用或禁用,寫保護狀態,四SPI設置,安全寄存器鎖定狀態、擦除/程序掛起狀態、輸出驅動程序強度、通電和當前地址模式。寫狀態寄存器指令可用于配置設備寫保護功能,四SPI設置,安全寄存器OTP鎖,保持/復位功能,輸出驅動器強度和通電地址模式。對狀態寄存器的寫訪問由非易失性狀態的狀態控制寄存器保護位(SRP0、SRP1)、寫啟用指令和標準/雙SPI期間操作,/WP引腳。

S0 BUSY 標志位:表示擦除或者寫入操作是否已經完成。(只讀)

BUSY is a read only bit in the status register (S0) that is set to a 1 state when the device is executing a Page Program, Quad Page Program, Sector Erase, Block Erase, Chip Erase, Write Status Register or Erase/Program Security Register instruction. During this time the device will ignore further instructions except for the Read Status Register and Erase/Program Suspend instruction (see tW, tPP, tSE, tBE, and tCE in AC Characteristics). When the program, erase or write status/security register instruction has completed, the BUSY bit will be cleared to a 0 state indicating the device is ready for further instructions.

BUSY是狀態寄存器(S0)中的只讀位,當設備執行頁程序、四頁程序、扇區擦除、塊擦除、芯片擦除、寫狀態寄存器或擦除/程序安全寄存器指令時,該位被設置為1狀態。在此期間,設備將忽略除讀取狀態寄存器和擦除/程序掛起指令外的其他指令(參見AC特性中的tW、tPP、tSE、tBE和tCE)。當程序、擦除或寫入狀態/安全寄存器指令完成時,忙位將被清除為0狀態,表示設備已準備好接受進一步指令。

FLASH指令

INSTRUCTIONS
The Standard/Dual/Quad SPI instruction set of the W25Q128FV consists of 45 basic instructions that are fully controlled through the SPI bus (see Instruction Set Table1-2). Instructions are initiated with the falling edge of Chip Select (/CS). The first byte of data clocked into the DI input provides the instruction code. Data on the DI input is sampled on the rising edge of clock with most significant bit (MSB) first.

W25Q128FV的標準/雙/四SPI指令集由45條基本指令組成,這些指令通過SPI總線完全控制(見指令集表1-2)。指令通過芯片選擇的下降沿(/CS)啟動。進入DI輸入的第一個數據字節提供指令代碼。DI輸入端上的數據首先在時鐘上升沿進行采樣,最高有效位(MSB)。

Instructions vary in length from a single byte to several bytes and may be followed by address bytes, data bytes, dummy bytes (don’t care), and in some cases, a combination. Instructions are completed with the rising edge of edge /CS. Clock relative timing diagrams for each instruction are included in Figures 5 through 57. All read instructions can be completed after any clocked bit. However, all instructions that Write, Program or Erase must complete on a byte boundary (/CS driven high after a full 8-bits have been clocked) otherwise the instruction will be ignored. This feature further protects the device from inadvertent writes. Additionally, while the memory is being programmed or erased, or when the Status Register is being written, all instructions except for Read Status Register will be ignored until the program or erase cycle has completed.

指令的長度從一個字節到幾個字節不等,后面可能是地址字節、數據字節、偽字節(不在乎),在某些情況下,還可能是一個組合。指令以edge/CS的上升沿完成。每個指令的時鐘相對時序圖包含在圖5到57中。所有讀取指令都可以在任何時鐘位之后完成。但是,所有寫入、編程或擦除的指令都必須在字節邊界上完成(/CS在完成8位時鐘后高電平驅動),否則該指令將被忽略。此功能進一步保護設備不受意外寫入的影響。此外,當存儲器被編程或擦除時,或當狀態寄存器被寫入時,除讀取狀態寄存器外的所有指令將被忽略,直到編程或擦除周期完成。

具體指令查閱參考手冊指令表。


總結

以上是生活随笔為你收集整理的《STM32从零开始学习历程》——SPI物理层及FLASH芯片介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。