SPI0 Initialization Issue on AMB82 MINI - "Invalid Pin selection 0" Error

SPI0 Initialization Issue on AMB82 MINI - “Invalid Pin selection 0” Error

Summary

SPI0 initialization fails on AMB82 MINI (RTL8735B) with persistent “Invalid Pin selection 0” and “Pin 0[0] is conflicted” errors, even when using correct SPI0 pins (12, 13, 14, 15). The HAL appears to attempt using Pin 0 (PF_5, JTAG) instead of the configured SPI0 pins.

Hardware & Software Environment

Board

  • Board: AMB82 MINI (Realtek RTL8735B)

  • Arduino Core: Realtek AmebaPro2 v4.0.9

  • IDE: Arduino IDE 1.8.x / 2.x

  • OS: macOS (Darwin 23.5.0)

Pin Configuration (from variant.h)


SPI0 pins (default):

- MOSI: Pin 13 (PE_3)

- MISO: Pin 14 (PE_2)

- SCLK: Pin 15 (PE_1)

- SS/CS: Pin 12 (PE_4)



SPI1 pins:

- MOSI: Pin 2 (PF_7)

- MISO: Pin 0 (PF_5) ← This pin is configured as RFAFE_CTRL/JTAG

- SCLK: Pin 1 (PF_6)

- SS/CS: Pin 3 (PF_8)

Library

  • ADS1256 Library: Custom modified version (based on Curious Scientist’s library)

  • Target Device: ADS1256 24-bit ADC

  • Connection: SPI0 (pins 12, 13, 14, 15), CS on Pin 10 (manual control)

Problem Description

Symptoms

  1. SPI.begin() or SPI.begin(12) appears to succeed (no immediate error)

  2. First call to SPI.transfer() triggers error sequence:

    
    [SSI  Err] spi_format(): Invalid Pin seleciton 0.
    
    [MISC Err] Pin 0[0] is conflicted
    
    [MISC Err] It's configured as RFAFE_CTRL/JTAG now.
    
    [MISC Err] It's using by peripheral 30000000
    
    [SSI  Err] PIN 0 cannot be registered.
    
    [SSI  Err] spi_format(): SPI 0 init fails.
    
    [SSI  Err] Please initialize SPI format first!
    
    
  3. Error occurs regardless of:

  • Using SPI.begin() or SPI.begin(12)

  • Removing all beginTransaction()/endTransaction() calls

  • Using different CS pins (tried Pin 10, Pin 12)

  • Initializing SPI before or after GPIO setup

  • Using ADS1256_SPI_ALREADY_STARTED flag

Key Observation

Pin 0 (PF_5) is NOT part of SPI0 configuration, yet HAL attempts to use it. Pin 0 is:

  • Part of SPI1 (MISO)

  • Configured as RFAFE_CTRL/JTAG by default

  • Not used in our SPI0 setup (pins 12/13/14/15)

Minimal Reproduction Code


#include <SPI.h>



void setup() {

Serial.begin(115200);

delay(2000);

Serial.println("=== SPI0 Test on AMB82 MINI ===");

  // Configure GPIO pins

pinMode(12, OUTPUT);  // CS (optional, tried with/without)

digitalWrite(12, HIGH);

  // Initialize SPI0

Serial.println("Initializing SPI0...");

SPI.begin();  // or SPI.begin(12)

SPI.setDefaultFrequency(1000000);

Serial.println("SPI0 initialized");

  // First SPI transfer triggers error

Serial.println("Attempting SPI.transfer(0x00)...");

uint8_t result = SPI.transfer(0x00);  // ← ERROR OCCURS HERE

Serial.print("Result: 0x");

Serial.println(result, HEX);

}



void loop() {

delay(1000);

}

Expected Behavior

  • SPI0 should initialize on pins 12/13/14/15

  • SPI.transfer() should work without errors

  • No reference to Pin 0 should occur

Actual Behavior

  • Error occurs on first SPI.transfer() call

  • HAL attempts to use Pin 0 (PF_5) instead of configured SPI0 pins

  • SPI0 initialization appears to fail internally

What We’ve Tried

1. Pin Configuration

  • :white_check_mark: Verified pin mapping from variant.h and variant.cpp

  • :white_check_mark: Confirmed SPI0 pins: 12 (PE_4), 13 (PE_3), 14 (PE_2), 15 (PE_1)

  • :white_check_mark: Tried different CS pins (10, 12)

  • :white_check_mark: Tried SPI1 pins (0, 1, 2, 3) - same error with Pin 0 conflict

2. Initialization Order

  • :white_check_mark: SPI.begin() before GPIO setup

  • :white_check_mark: SPI.begin() after GPIO setup

  • :white_check_mark: SPI.begin(12) with explicit SS pin

  • :white_check_mark: Removed all pinMode() calls before SPI.begin()

3. Library Modifications

  • :white_check_mark: Removed all beginTransaction()/endTransaction() calls

  • :white_check_mark: Added ADS1256_SPI_ALREADY_STARTED flag

  • :white_check_mark: Modified library to skip _spi->begin() for Ameba

  • :white_check_mark: Moved GPIO setup from constructor to InitializeADC()

4. FreeRTOS SDK API Attempt

  • :white_check_mark: Created wrapper using spi_init(), spi_format(), spi_frequency()

  • :cross_mark: Same pin conflict errors occurred

  • :cross_mark: spi_init() with SPI0 pins (PE_1, PE_2, PE_3, PE_4) failed

5. Peripheral Conflicts

  • :white_check_mark: Checked for I2C2 conflicts (pins 12/13)

  • :white_check_mark: Checked for Serial3 conflicts (pins 14/15)

  • :white_check_mark: Attempted to deinitialize Wire1/Serial3 (not available in core)

Error Log Analysis

Error Sequence


[SSI  Err\] spi_format(): Invalid Pin seleciton 0.

  • HAL attempts to format SPI with Pin 0

  • Pin 0 is not part of SPI0 configuration


[MISC Err] Pin 0[0] is conflicted

[MISC Err] It's configured as RFAFE_CTRL/JTAG now.

[MISC Err] It's using by peripheral 30000000

  • Pin 0 (PF_5) is already configured as JTAG/trace

  • Cannot be reassigned to SPI


[SSI  Err] PIN 0 cannot be registered.

[SSI  Err] spi_format(): SPI 0 init fails.

  • SPI format initialization fails

  • Subsequent SPI.transfer() calls fail

Hypotheses

Hypothesis 1: HAL Bug

The HAL SPI implementation may have a bug where it incorrectly references Pin 0 (PF_5) when initializing SPI0, even though SPI0 uses pins 12/13/14/15.

Hypothesis 2: Pinmux Configuration Issue

The pinmux may not be correctly configured for SPI0, causing the HAL to fall back to default pins (Pin 0) or SPI1 configuration.

Hypothesis 3: JTAG/Trace Interference

Pin 0 (PF_5) is hardcoded as JTAG/trace in the bootloader/SDK, and cannot be released for SPI use, even for SPI0 which doesn’t need it.

Hypothesis 4: SPI Object Initialization

The default SPI object may be incorrectly mapped to SPI1 internally, causing it to attempt using SPI1 pins (including Pin 0).

Questions for the Community

  1. Has anyone successfully used SPI0 on AMB82 MINI? If yes, what was the exact initialization sequence?

  2. Is Pin 0 (PF_5) permanently reserved for JTAG? Can it be released, or is there a way to disable JTAG/trace?

  3. Is there a known workaround for this SPI initialization issue?

  4. Should we use a different SPI object? (e.g., SPI1 instead of SPI, or a custom SPIClass instance)

  5. Is there a HAL patch or updated core version that fixes this issue?

  6. Are there any special initialization steps required for SPI on AMB82 MINI that differ from standard Arduino SPI?

Additional Information

Files Modified

  • /Users/inxnik/nikita/58_scales_2/Code/08_ADS_SPI_Ameba/ADS1256.cpp

-/Users/inxnik/nikita/58_scales_2/Code/08_ADS_SPI_Ameba/test_simple_ameba_SPI1/test_simple_ameba_SPI1.ino

Related Documentation

  • AMB82 MINI Pin Definition: variant.h, variant.cpp

  • SPI Library: /Arduino15/packages/realtek/hardware/AmebaPro2/4.0.9/libraries/SPI/

  • FreeRTOS SDK SPI Example: /45_ameba/06_FreeRTOS SDK/ameba-rtos-pro2/project/realtek_amebapro2_v0_example/example_sources/spi/

Working Configuration (ESP32)

The same ADS1256 library and code works perfectly on ESP32-S3 with:

  • SPIClass hspi(HSPI);

  • hspi.begin(14, 25, 13); (SCK, MISO, MOSI)

  • No pin conflicts or initialization issues

Request for Help

We’ve spent significant time troubleshooting this issue and believe it may be a platform-specific bug or configuration issue. Any guidance, workarounds, or patches would be greatly appreciated.

Contact: [Your contact info if desired]

Date: 2026-01-05


Appendix: Complete Error Log


=== Простой тест ADS1256 на AMB82 MINI (SPI0) ===

Serial работает!

Инициализация SPI0...

✓ SPI0 инициализирован

   Пины SPI0:

   MOSI=Pin 13 (PE_3), MISO=Pin 14 (PE_2), SCLK=Pin 15 (PE_1), CS=Pin 10 (PF_12)

Инициализация ADS1256...

[SSI  Err][31mspi_format(): Invalid Pin seleciton 0.

[0m

[MISC Err]Pin 0[0] is conflicted

[MISC Err]It's configured as RFAFE_CTRL/JTAG now.

[MISC Err]It's using by peripheral 30000000

[SSI  Err]PIN 0 cannot be registered.

[SSI  Err][31mspi_format(): SPI 0 init fails.

[0m

[SSI  Err]Please initialize SPI format first!

[SSI  Err]Please initialize SPI format first!

Hi @inxnik ,

Try removing the following two lines or lines that may be using the SPI0 pins before SPI.begin() is called and see if your application works.

pinMode(12, OUTPUT);
digitalWrite(12, HIGH);

I believe this could be the issue at this point because this seems to be causing a pin check to fail when SPI.begin() is called. I have tried running some SPI examples using the set of pins for SPI0 and they are able to work just fine. Let me know if you encounter any other issues after removing the code.

Problem: ADS1256 on AMB82 MINI (AmebaPro2) via SPI

I’ve successfully set up SPI on the AMB82 MINI, but I cannot get the ADS1256 to respond. The same library works perfectly on ESP32-S3, but porting it to AmebaPro2 fails.

Working ESP32 library: CuriousScientist0/ADS1256

Platform / Setup:

  • Microcontroller: AMB82 MINI (AmebaPro2)

  • Arduino Core: AmebaPro2 v4.0.9

  • ADC: ADS1256 (24-bit)

  • SPI: SPI0

    • SCLK: PE_1 / Pin 15

    • MOSI: PE_3 / Pin 13

    • MISO (DOUT): PE_2 / Pin 14

    • CS: PF_12 / Pin 10 (manual)

    • DRDY: PB_4 / Pin 22 (working)

    • POWN: PB_5 / Pin 21

    • Power: 5 V via V_USB

SPI settings:

  • 500 kHz, SPI_MODE1, MSBFIRST

  • Standard SPI library for AmebaPro2

What works:

  • SPI.begin() and SPI.transfer() work

  • DRDY toggles → ADS1256 alive

  • POWN works

  • Physical wiring verified

Problem:

  • MISO always reads 0x0

  • Commands (RESET, RDATA, RREG, etc.) return 0x0

  • Cannot read registers

  • Likely issue with MISO pin handling or SPI implementation on AMB82 MINI

Tried:

  • Different SPI modes and frequencies

  • beginTransaction()

  • Correct command timing

  • Physical wiring checks

  • Attempting SPI1

Goal:

  • Port the working ESP32 ADS1256 library to AmebaPro2

  • Support standard SPI0 or SPI1

  • Full functionality: register access, data reading

  • Open source release, willing to pay for help

Looking for a specialist who can help port the working ADS1256 library from ESP32 to AmebaPro2. Ready to pay for the work Will make the library available to everyone (open source, GitHub

Contact: DM or inxnik@gmail.com

1 Like

I have an update

ADS1256 on AMB82 MINI - Working Solution

Successfully implemented ADS1256 (24-bit ADC) communication on AMB82 MINI (Realtek AmebaPro2) using Software SPI (bit-banging).

WORKING - Stable data reading with noise < 10 RAW

  • Reading RAW 24-bit values from ADS1256
  • Register configuration (STATUS, MUX, ADCON, DRATE)
  • Load Cell support (differential mode AIN0/AIN1)
  • Stable communication with low noise (5-6 RAW amplifier noise)

During development, we encountered issues with hardware SPI:

  1. SPI0 conflict: SPI0 pins (PE1/PE2) conflict with Serial3 on AMB82 MINI
  2. SPI1 MISO bug: Hardware SPI1 MISO (Pin 0) always reads 0x0 - confirmed by loopback test

Solution: Implemented Software SPI via GPIO, which works reliably.

Has anyone successfully used hardware SPI1 (or SPI0) with ADS1256 on AMB82 MINI?

The loopback test (MOSI → MISO) showed that SPI1 MISO always returns 0x0, suggesting a hardware/SDK bug. If you have a working hardware SPI solution, please share!

Pinout

AMB82 MINI ADS1256 Description
Pin 1 (PF6) SCLK Serial Clock
Pin 2 (PF7) DIN Data In
Pin 0 (PF5) DOUT Data Out
Pin 10 CS Chip Select
Pin 22 DRDY Data Ready
Pin 21 PWDN Power Down

Key Implementation Details

  • SPI Mode: MODE1 (CPOL=0, CPHA=1)
  • Bit Order: MSBFIRST
  • Frequency: ~125 kHz (2 μs delays)
  • Settings: PGA x16, 10 SPS, VREF 2.5V

Test sketch:

I need hardware SPI investigation (if possible)

If you have experience with:

  • Hardware SPI1/SPI0 on AMB82 MINI
  • ADS1256 on other AmebaPro2 boards
  • Alternative solutions

Please share your findings!