dcexpert 发表于 2021-5-27 15:41

64Mb PSRAM 的简单驱动

本帖最后由 dcexpert 于 2021-5-27 15:41 编辑

<p>64Mbit(8兆字节)的PSRAM让人兴奋,虽然速度不是最快,但是却很有用。</p>

<p>&nbsp;</p>

<p>**** Hidden Message *****</p>

<p>&nbsp;</p>

<p>example.py 显示了如何使用它,只需给它一个地址(范围0-8388607)和一个值(范围0-255),就可以将数据从&nbsp;bytearray 转换为整数。</p>

<p>&nbsp;</p>

<pre>
<code class="language-python">
"""
mb_PSRAM_64Mb_SPI_example.py
Example MicroPython script for 64Mbit SPI PSRAM with RP2040 (Raspberry Pi Pico)
(Should work with other MicroPython-capable devices with hardware of software SPI)
Author: mark@marksbench.com
Version: 0.1, 2021-05-26
**NOTE: There is no guarantee that this software will work in the way you expect (or at all).
**Use at your own risk.
To use:
- Upload the mb_PSRAM_64Mb_SPI.py file to your board (the same location where your MicroPython scripts
run from, or the /lib folder if applicable).
- Connect the PSRAM to the Pi Pico (RP2040), for testing (and to use this example script
without modification) I suggest the following:

      PSRAM    |    Pi Pico
      1(/CE)   |    GP1 (Pin 2)
      2(SO)    | GP4, (SPI0 RX, Pin 6)
      3(SIO)|      NC
      4(Vss)   |    GND, (Pin 38)
      5(SI)    | GP7, (SPI0 TX, Pin 10)
      6(SCK)   | GP6, (SPI0 SCK, Pin 9)
      7(SIO)|      NC
      8(Vcc)   |   3V3 OUT, (Pin 36)
- To write a value: memory.write_byte(address, value)
- To read a value: value = memory.read_byte(address)
- You should get an error if the address or value is out of range.
"""

from machine import Pin, SPI
import mb_PSRAM_64Mb_SPI

# Set up SPI with the pinout arrangement listed above
spi = SPI(0, sck=Pin(6), mosi=Pin(7), miso=Pin(4), polarity=0, phase=0, baudrate=2000000)

# Set a GP pin to use for /CS
cs = 1

# Create constructor to use driver
memory = mb_PSRAM_64Mb_SPI.mb_PSRAM_64Mb_SPI(spi, cs)


# Simple write test. Writing value of 38 to address 8388607 (highest address of this device)
memory.write_byte(8388607, 38)

# Write value 255 to address 0 (lowest address of the 23LC1024)
memory.write_byte(0, 255)

# Simple read test. Read the value from address 131071 and print it
read_value = memory.read_byte(8388607)
print("Retrieved: ", read_value)

# Now read from address 0 and print it
read_value = memory.read_byte(0)
print("Retrieved: ", read_value)</code></pre>

<p>&nbsp;</p>

w494143467 发表于 2021-5-27 17:21

<p>这个是用的什么芯片?</p>

annysky2012 发表于 2021-5-27 20:29

<p>一般应用在哪里?</p>

leiyong711 发表于 2022-2-7 17:13

<p>这个好</p>

BINGTANGXUELI 发表于 2022-2-20 15:35

<p>不错哦,下载下来看看</p>

testox 发表于 2022-3-16 07:50

<p>RP2040就是引脚少了点</p>

zhangdezhi18 发表于 2022-5-9 13:46

回复看看啊

p18727955905 发表于 2025-1-9 11:05

<p>学习学习</p>

wangshujun72 发表于 2025-1-16 15:54

<p>看一下</p>
页: [1]
查看完整版本: 64Mb PSRAM 的简单驱动