hwconfig: Fix pad config for SD SPI, move clockrate to hwconfig
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m19s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 9s
Run pytests / Check-Pytest (push) Successful in 11s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m19s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 9s
Run pytests / Check-Pytest (push) Successful in 11s
The code snippet in hwconfig to adjust the drive strength was incorrect: It was adjusting the wrong pins. This was probably not updated during some pin shuffling in the breadboard phase. Fix this by adjusting the correct pins. Experimentation shows that both setting the slew rate to fast or setting the drive strength to 8 mA (default: slow and 4 mA) is sufficient to make SD SPI work at 25 MHz on the Rev1 PCB. For now, the combination 8 mA and slow is chosen (slow slew rate should result in less high frequency EMI). Also make the SD clock rate adjustable in hwconfig, and set it to 25 MHz for Rev1 and 15 MHz for the breadboard setup. Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
@@ -9,6 +9,7 @@ SD_DI = Pin.board.GP3
|
||||
SD_DO = Pin.board.GP4
|
||||
SD_SCK = Pin.board.GP2
|
||||
SD_CS = Pin.board.GP5
|
||||
SD_CLOCKRATE = 25000000
|
||||
|
||||
# MAX98357
|
||||
I2S_LRCLK = Pin.board.GP6
|
||||
@@ -46,10 +47,11 @@ def board_init():
|
||||
POWER_EN.init(mode=Pin.OUT)
|
||||
POWER_EN.value(1)
|
||||
|
||||
# Set 8 mA drive strength and fast slew rate for SD SPI
|
||||
machine.mem32[0x4001c004 + 6*4] = 0x67
|
||||
machine.mem32[0x4001c004 + 7*4] = 0x67
|
||||
machine.mem32[0x4001c004 + 8*4] = 0x67
|
||||
# SD_DO / MISO input doesn't need any special configuration
|
||||
# Set 8 mA drive strength for SCK and MOSI
|
||||
machine.mem32[0x4001c004 + 2*4] = 0x60 # SCK
|
||||
machine.mem32[0x4001c004 + 3*4] = 0x60 # MOSI
|
||||
# SD_CS doesn't need any special configuration
|
||||
|
||||
# Permanently enable amplifier
|
||||
# TODO: Implement amplifier power management
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
|
||||
import machine
|
||||
from machine import Pin
|
||||
|
||||
# SD Card SPI
|
||||
@@ -9,6 +8,7 @@ SD_DI = Pin.board.GP3
|
||||
SD_DO = Pin.board.GP4
|
||||
SD_SCK = Pin.board.GP2
|
||||
SD_CS = Pin.board.GP5
|
||||
SD_CLOCKRATE = 15000000
|
||||
|
||||
# MAX98357
|
||||
I2S_LRCLK = Pin.board.GP7
|
||||
@@ -41,10 +41,7 @@ VBAT_ADC = Pin.board.GP26
|
||||
|
||||
|
||||
def board_init():
|
||||
# Set 8 mA drive strength and fast slew rate for SD SPI
|
||||
machine.mem32[0x4001c004 + 6*4] = 0x67
|
||||
machine.mem32[0x4001c004 + 7*4] = 0x67
|
||||
machine.mem32[0x4001c004 + 8*4] = 0x67
|
||||
pass
|
||||
|
||||
|
||||
def get_battery_voltage():
|
||||
|
||||
@@ -62,7 +62,7 @@ def run():
|
||||
|
||||
# Setup MP3 player
|
||||
with SDContext(mosi=hwconfig.SD_DI, miso=hwconfig.SD_DO, sck=hwconfig.SD_SCK, ss=hwconfig.SD_CS,
|
||||
baudrate=15000000), \
|
||||
baudrate=hwconfig.SD_CLOCKRATE), \
|
||||
AudioContext(hwconfig.I2S_DIN, hwconfig.I2S_DCLK, hwconfig.I2S_LRCLK) as audioctx:
|
||||
|
||||
# Setup NFC
|
||||
|
||||
Reference in New Issue
Block a user