百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rp2040-psram

> 编程语言
开源

一个仅包含头文件的 C 库,可通过 RP2040 微控制器上的 PIO 访问 SPI PSRAM。

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个仅包含头文件的 C 库,可通过 RP2040 微控制器上的 PIO 访问 SPI PSRAM。

rp2040-psram

A header-only C library to allow access to SPI PSRAM via PIO on the RP2040 microcontroller as used on the Raspberry Pi Pico. Due to the timing requirements of these PSRAM devices, reading data from them at high speed (>84MHz) requires the following clock behavior:

  • Read data needs to be sampled on the clock falling edge.
  • An extra "fudge factor" clock cycle is required before reading data.

I could not get the hardware SPI interface on the RP2040 to work at high speed with this behavior, so I created a PIO SPI implementation specifically tailored to the behavior of the PSRAM chips and optimized for the highest speed possible:

  • A read or write command is given, followed by an optional read of data.
  • Chip select is driven by PIO.
  • DMA is used so CPU cycles are not used to service the PIO TX and RX FIFOs.
  • Special optimized functions are provided for writing 8, 16, and 32 bit data as fast as possible.
  • All functions are tagged with __force_inline for the fastest speed possible.

Tested PSRAM chips:

  • apmemory APS6404L
  • Lyontek LY68L6400
  • IPUS IPS6404
  • Espressif ESP-PSRAM64H

These chips have been tested as stable up to an RP2040 clock speed of 280MHz, creating an effecitve SPI clock speed of 140MHz.

Examples

An example that tests the PSRAM by writing and reading 8MB of data with 8, 16, 32, and 128 bit access sizes is included in the examples/ directory.

Using this library

Hardware connections

Due to using sideset to drive the CS and SCK signals, those two pins must be on consecutive GPIOs. For example, if CS is on GPIO 0, SCK must be on GPIO 1. MOSI and MISO may be on any pin and do not need to be adjacent.

QSPI support is on the roadmap for the future. If you plan on using QSPI, SIO[0] through SIO[3] must be on consecutive GPIOs.

Including in the build

Clone this repository and copy to a subdirectory or add as a submodule in your project. In your project's CMakeLists.txt file, add the following:

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/rp2040-psram rp2040-psram)

And then add rp2040-psram to your project's target_link_libraries.

Using in your code

Include psram_spi.h in your file. See the documentation for this file for how to initialize and use this library.

The following defines MUST be defined:

  • PSRAM_PIN_CS - GPIO number of the chip select pin
  • PSRAM_PIN_SCK - GPIO number of the clock pin
  • PSRAM_PIN_MOSI - GPIO number of the MOSI pin
  • PSRAM_PIN_MISO - GPIO number of the MISO pin

Optional define:

  • PSRAM_MUTEX - Define this to put PSRAM access behind a mutex. This must be used if the PSRAM is to be used by multiple cores.

Projects that use rp2040-psram

PicoGUS - uses PSRAM to emulate the Gravis Ultrasound's 1MB sample RAM

License

rp2040-psram is licensed under the MIT license (see LICENSE)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Cpsramraspberry-pi-picorp2040spi

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言