I'm working on a project where I need to interface a Pico W with an ADS1263 using SPI, and when I try to read the ID register (which should return 0x30 according to the datasheet), I'm consistently getting 0x00 back. It seems DRDY isn't ready and SPI communication isn't working at all.
ADS1263 → Pico W
SCK → GP2 (Pin 4)
DIN (MOSI) → GP3 (Pin 5)
DOUT (MISO) → GP4 (Pin 6)
CS → GP5 (Pin 7)
DRDY → GP20 (Pin 26)
RESET → GP21 (Pin 27)
5V → VSYS (Pin 39)
GND → GND (Pin 38)
I already confirmed power, and pins wiring.
here's my code that assisted by Claude.
from machine import Pin, SPI
import utime
SCK_PIN = 2
MOSI_PIN = 3
MISO_PIN = 4
CS_PIN = 5
DRDY_PIN = 20
RESET_PIN = 21
CMD_RESET = 0x06
CMD_START1 = 0x08
CMD_STOP1 = 0x0A
CMD_RDATA1 = 0x12
CMD_SYOCAL1 = 0x16
CMD_SYGCAL1 = 0x17
CMD_SFOCAL1 = 0x19
CMD_RREG = 0x20
CMD_WREG = 0x40
REG_ID = 0x00
REG_POWER = 0x01
REG_INTERFACE = 0x02
REG_MODE0 = 0x03
REG_MODE1 = 0x04
REG_MODE2 = 0x05
def init_gpio():
print("\n" + "="*60)
print("STEP 1: Initializing GPIO Pins")
print("="*60)
cs = Pin(CS_PIN, Pin.OUT)
cs.value(1)
print(f"CS pin (GP{CS_PIN}) initialized - Set HIGH (disabled)")
reset = Pin(RESET_PIN, Pin.OUT)
reset.value(1)
print(f"RESET pin (GP{RESET_PIN}) initialized - Set HIGH (inactive)")
drdy = Pin(DRDY_PIN, Pin.IN, Pin.PULL_UP)
print(f"DRDY pin (GP{DRDY_PIN}) initialized - Input with pull-up")
return cs, reset, drdy
def init_spi():
print("\n" + "="*60)
print("STEP 2: Initializing SPI Bus")
print("="*60)
spi = SPI(0,
baudrate=1000000,
polarity=0,
phase=1,
bits=8,
firstbit=SPI.MSB,
sck=Pin(SCK_PIN),
mosi=Pin(MOSI_PIN),
miso=Pin(MISO_PIN))
print(f"SPI0 initialized:")
print(f" - SCK: GP{SCK_PIN}")
print(f" - MOSI: GP{MOSI_PIN} (DIN on ADS1263)")
print(f" - MISO: GP{MISO_PIN} (DOUT on ADS1263)")
print(f" - Baudrate: 1 MHz")
print(f" - Mode: 1 (CPOL=0, CPHA=1)")
return spi
def hardware_reset(reset_pin, cs_pin):
print("\n" + "="*60)
print("STEP 3: Performing Hardware Reset")
print("="*60)
cs_pin.value(1)
print("CS set HIGH")
print("Pulsing RESET pin LOW...")
reset_pin.value(0)
utime.sleep_ms(10)
reset_pin.value(1)
print("RESET pin returned HIGH")
utime.sleep_ms(100)
print("Reset complete - waited 100ms for device stabilization")
def send_command(spi, cs_pin, command, description=""):
cs_pin.value(0)
utime.sleep_us(1)
spi.write(bytearray([command]))
utime.sleep_us(1)
cs_pin.value(1)
if description:
print(f"Sent command: 0x{command:02X} ({description})")
def check_drdy_initial(drdy_pin):
print("\n" + "="*60)
print("STEP 4: Checking Initial DRDY State")
print("="*60)
initial_state = drdy_pin.value()
if initial_state == 1:
print("DRDY is HIGH (no data ready - expected after reset)")
else:
print("DRDY is LOW (data might be ready)")
return initial_state
def start_conversion(spi, cs_pin):
print("\n" + "="*60)
print("STEP 5: Starting ADC1 Conversion")
print("="*60)
send_command(spi, cs_pin, CMD_START1, "START1 - Begin conversions")
utime.sleep_ms(10)
print("Conversion started - waiting for DRDY to go LOW...")
def monitor_drdy(drdy_pin, duration_seconds=10, check_interval_ms=10):
print("\n" + "="*60)
print("STEP 6: Monitoring DRDY Pin")
print("="*60)
print(f"Monitoring for {duration_seconds} seconds...")
print(f"Check interval: {check_interval_ms}ms")
print("-"*60)
previous_state = drdy_pin.value()
start_time = utime.ticks_ms()
transition_count = 0
high_count = 0
low_count = 0
print(f"[{utime.ticks_ms() - start_time:6d}ms] Initial DRDY state: {'HIGH' if previous_state else 'LOW'}")
while utime.ticks_diff(utime.ticks_ms(), start_time) < (duration_seconds * 1000):
current_state = drdy_pin.value()
if current_state == 1:
high_count += 1
else:
low_count += 1
if current_state != previous_state:
transition_count += 1
elapsed = utime.ticks_ms() - start_time
if current_state == 0:
print(f"[{elapsed:6d}ms] DRDY went LOW (Data Ready!) [Transition #{transition_count}]")
else:
print(f"[{elapsed:6d}ms] DRDY went HIGH (Data read or waiting) [Transition #{transition_count}]")
previous_state = current_state
utime.sleep_ms(check_interval_ms)
print("-"*60)
print("MONITORING COMPLETE - SUMMARY:")
print(f" Total transitions: {transition_count}")
print(f" HIGH readings: {high_count}")
print(f" LOW readings: {low_count}")
if transition_count == 0:
print("\nWARNING: No DRDY transitions detected!")
print(f" Final state: {'HIGH' if current_state else 'LOW'}")
elif transition_count > 0:
print(f"\nSUCCESS: DRDY is toggling! ({transition_count} transitions)")
return transition_count
def read_register(spi, cs_pin, reg_addr):
cs_pin.value(0)
utime.sleep_us(5)
# RREG command: 0x20 | (reg_addr << 2), then number of bytes - 1
spi.write(bytearray([0x20 | (reg_addr << 2), 0x00]))
utime.sleep_us(5)
data = spi.read(1)
utime.sleep_us(5)
cs_pin.value(1)
return data[0]
def main():
print("\n" + "="*60)
print("ADS1263 DRDY PIN VERIFICATION TEST")
print("="*60)
print("Purpose: Verify DRDY pin toggles when ADC conversion occurs")
print("Expected: DRDY HIGH initially, goes LOW when data ready")
try:
cs, reset, drdy = init_gpio()
spi = init_spi()
hardware_reset(reset, cs)
check_drdy_initial(drdy)
start_conversion(spi, cs)
transitions = monitor_drdy(drdy, duration_seconds=10, check_interval_ms=10)
print("\n" + "="*60)
print("TEST COMPLETE")
print("="*60)
if transitions > 0:
print("TEST PASSED")
print("DRDY pin is functioning correctly!")
print(f"Detected {transitions} transitions in 10 seconds")
else:
print("TEST FAILED")
print("No DRDY transitions detected")
print("See troubleshooting section below")
# Add this after hardware_reset()
print("\nReading ID register (should be 0x30 for ADS1263)...")
id_value = read_register(spi, cs, REG_ID)
print(f"ID register value: 0x{id_value:02X}")
if id_value == 0x30:
print("SUCCESS: SPI communication working!")
else:
print(f"PROBLEM: Expected 0x30, got 0x{id_value:02X}")
except Exception as e:
print(f"\nERROR: {e}")
import sys
sys.print_exception(e)
if __name__ == "__main__":
main()