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
-
SPI.begin()orSPI.begin(12)appears to succeed (no immediate error) -
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! -
Error occurs regardless of:
-
Using
SPI.begin()orSPI.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_STARTEDflag
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
-
Verified pin mapping from variant.handvariant.cpp -
Confirmed SPI0 pins: 12 (PE_4), 13 (PE_3), 14 (PE_2), 15 (PE_1) -
Tried different CS pins (10, 12) -
Tried SPI1 pins (0, 1, 2, 3) - same error with Pin 0 conflict
2. Initialization Order
-
SPI.begin()before GPIO setup -
SPI.begin()after GPIO setup -
SPI.begin(12)with explicit SS pin -
Removed all pinMode()calls beforeSPI.begin()
3. Library Modifications
-
Removed all beginTransaction()/endTransaction()calls -
Added ADS1256_SPI_ALREADY_STARTEDflag -
Modified library to skip _spi->begin()for Ameba -
Moved GPIO setup from constructor to InitializeADC()
4. FreeRTOS SDK API Attempt
-
Created wrapper using spi_init(),spi_format(),spi_frequency() -
Same pin conflict errors occurred -
spi_init()with SPI0 pins (PE_1, PE_2, PE_3, PE_4) failed
5. Peripheral Conflicts
-
Checked for I2C2 conflicts (pins 12/13) -
Checked for Serial3 conflicts (pins 14/15) -
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
-
Has anyone successfully used SPI0 on AMB82 MINI? If yes, what was the exact initialization sequence?
-
Is Pin 0 (PF_5) permanently reserved for JTAG? Can it be released, or is there a way to disable JTAG/trace?
-
Is there a known workaround for this SPI initialization issue?
-
Should we use a different SPI object? (e.g.,
SPI1instead ofSPI, or a customSPIClassinstance) -
Is there a HAL patch or updated core version that fixes this issue?
-
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!