顯示具有 SPI 標籤的文章。 顯示所有文章
顯示具有 SPI 標籤的文章。 顯示所有文章

2026年5月20日 星期三

FPGA/STM32 SPI 實驗

本實驗中,Nucleo H753ZI 當作 SPI Master,PYNQ-Z2 當作 SPI Slave。

使用SPI通訊協定傳送及接收8 Bytes。


腳位設定如下:


Nucleo H753ZI

功能

PYNZ-Z2

PD14

CS

W9

PA5

SCLK

Y8

PD7

MOSI

W8

PA6

MISO

Y19 (Y17腳位故障)








  1. 使用AXI QUAD SPI

SPI Slave接收不到資料。

  1. 即使SPI Master的Prescaler設為256(187.5KBit/s)SPI Slave仍接收不到資料

  2. 使用Digital LA分析訊號正常

  3. 使用Vivado ILA分析訊號正常

  4. 原因:使用杜邦線連接兩片開發板,可能產生訊號抖動, 用LA未必能發現訊號抖動問題


  1. 使用自行開發的 SPI Slave IP
    用GPIO0的2個channel(64bit)接收8 Bytes, 用GPIO1的的2個channel(64bit)傳送8 Bytes,GPIO2的1 bit做為rx valid。

  1. 去除CS抖動
    CS連續15 clock為high才重置, CS為low則立即啟動接收資

  2.  SPI Slave可以接收到資料, SPI Master收到的回傳資料皆位移1 bit

原因:第一次取樣(第一個 SCK 上升沿)時,錯過了第 1 個 bit (Bit 63),直接讀到了第 2 個 bit (Bit 62)。

解決:調整SPI Slave的PS FCLK_CLK0為150MHz。


  1. SPI Master Prescaler設定為2(24Mbit/s)可以正常傳送接收資料。









2024年2月17日 星期六

ZYNQ add SPI interface and petalinux device tree

 ZYNQ add SPI interface

  1. Open “Open Block Diagram”
  2. Add “AXI QUAD SPI” block
  3. Run “Run Conection Automation”
  4. Generate Bitstream
  5. Open “Open Implementation Design”
  6. Switch to “I/O Planning” and select “I/O Ports”

  1. Pin assign for SPI interface


  1. Generate Bitstream and export hardware

Customize SPI device tree for petalinux

After update HDF and execute command: petalinux-config –get-hw-description=<HDF Directory>

In components/plnx_workspace/device-tree/device-tree/pl.dtsi, will produce SPI device node automatically as below:

Modify project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi as below

Enable SPI device driver

$ petalinux-config -c kernel

Go to Device Drivers -> SPI Support -> User mode SPI device driver support and enable it.

Use spidev_test.c to verify the SPI interface.

$ ls /dev/spi*

$ gcc spidev_test.c -o spidev_test

$ ./spidev_test -D /dev/spidev1.0

FPGA/STM32 SPI 實驗

本實驗中,Nucleo H753ZI 當作 SPI Master,PYNQ-Z2 當作 SPI Slave。 使用SPI通訊協定傳送及接收8 Bytes。 腳位設定如下: Nucleo H753ZI 功能 PYNZ-Z2 PD14 CS W9 PA5 SCLK...