SPI1 MISO Issue on AMB82 MINI

On AMB82 MINI, SPI1 MISO (Pin 0 / PF5) always reads 0x00, no matter what data is sent on MOSI. Because of this, hardware SPI communication with peripherals does not work.

Hardware / Software

  • Board: AMB82 MINI (RTL8735B)

  • SDK: Realtek Ameba Boards 4.0.9

  • SPI1 pins:

    • MISO: Pin 0 (PF5)

    • MOSI: Pin 2 (PF7)

    • SCLK: Pin 1 (PF6)

Tests and Observations

Loopback test

MOSI (Pin 2) was physically connected to MISO (Pin 0).

Sending 0xAA always returns 0x00.

This suggests that SPI1 MISO is not actually receiving data.

Pinmux conflict

When initializing SPI1, the following error appears:

[MISC Err] Pin 5[5] is conflicted
[MISC Err] It's using by peripheral F0000000
[SSI Err] PIN a5 cannot be registered.

What was tried

  1. Loopback test (confirms MISO issue)

  2. Removing CS pinMode before SPI.begin()

  3. Setting pinMode(0, INPUT) before SPI1.begin()

  4. Testing SPI0 (MISO on Pin 14) — same result

  5. Disabling FreeRTOS interrupts

  6. Minimal SPI initialization code

All cases behave the same: MISO always returns 0x00.

Current workaround

Software SPI (bit-banging) works reliably, but hardware SPI is preferred for performance and stability.

Questions

  1. Is SPI1 MISO on AMB82 MINI actually supported and usable?

  2. What peripheral is occupying PF5 (shown as F0000000)?

  3. Is there a known fix or recommended workaround for this issue?

Thanks for any clarification or guidance.

Hello @inxnik ,

The error looks identical to the one before, does your fix for SPI0 not work for SPI1 too? If not, please share what you did to fix your issue with SPI0 so we can try other methods to figure out the problem better.

Meanwhile please give our SPI example a try and check if your SPI0 and SPI1 are working as intended. You can find it within {SDK}\project\realtek_amebapro2_v0_example\example_sources\spi_master_write_read_one_byte\src\main.c", this sets SPI0 as slave and SPI1 as master.

I have also compiled and ran the example with SPI0 as master and SPI1 as slave instead. The example worked both times when SPI0 is connected SPI1 and when both SPIs’ looped back to themselves as in your loopback test.

flash_ntz.zip (497.1 KB)

Hi, Thank you for the example. I understand the FreeRTOS SDK approach.

However, Arduino IDE uses different API (`SPI1.begin()` vs `spi_init()`) and **SPI1 MISO still returns 0x00** in Arduino IDE, even after removing CS pinMode before SPI.begin().

— Can we use FreeRTOS SDK SPI API (`spi_init()`, `spi_format()`) from Arduino IDE, or should we switch to FreeRTOS SDK?

Thank you.

Hello @inxnik ,

Sorry it slipped my mind to keep it within Arduino. Rest assured you will be fine sticking with our Arduino SDK as we have designed it to be identical to our FreeRTOS’s SDK. I have converted the example to a simpler one to be used with the ArduinoIDE. Please test it with your AMB82-Mini and let me know how it goes! :crossed_fingers:

Master SPI0 and Slave SPI1. The loopback test should pass for both sides too.

#include <SPI.h>

void setup() {

Serial.begin(115200);

delay(2000);

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

SPI.begin(SPI_MODE_MASTER);
SPI1.begin(SPI_MODE_SLAVE);

Serial.println("SPI0 and SPI1 initialized");
Serial.println("Begin Slave Send and Read");

SPI1.slaveWrite(0x44);
uint8_t masterRead = SPI.masterWrite(0x55);
Serial.print("masterRead: 0x");
Serial.println(masterRead, HEX);

uint8_t slaveRead = SPI1.slaveRead();
Serial.print("slaveRead: 0x");
Serial.println(slaveRead, HEX);

}

void loop() {
delay(1000);
}
1 Like

Sorry, Hi, I tested the SPI loopback code you sent but it’s not working. I connected the pins as required (SPI0_MOSI to SPI1_MISO, SPI0_MISO to SPI1_MOSI, SPI0_SCLK to SPI1_SCLK) but the test fails.

Expected masterRead 0x44 and slaveRead 0x55, but got masterRead 0xFF and slaveRead 0x0. Looks like SPI1 slave mode isn’t working properly or the slaveWrite/slaveRead methods have issues.

Hi @inxnik ,

I see! The MOSI and MISO pins must be connected to each other as in SPI0_MOSI ↔ SPI1_MOSI and SPI0_MISO ↔ SPI1_MISO. Please try the example again after adjusting the pin connections. The output should look like this:

=== SPI1 Test on AMB82 MINI ===
Initializing SPI0 and SPI1
SPI0 and SPI1 initialized
Begin Slave Send and Read
masterRead: 0x44
slaveRead: 0x55

If that still does not go as expected let us test for other potential issues.

  1. Please try the same example but with the SPIs’ MISO and MOSI connected to themselves.
    (eg. SPI1_MISO ↔ SPI1_MOSI) You should be getting an output that looks like this.
=== SPI1 Test on AMB82 MINI ===
Initializing SPI0 and SPI1
SPI0 and SPI1 initialized
Begin Slave Send and Read
masterRead: 0x55
slaveRead: 0x44
  1. Test the set of SPI pins (PF5, PF6, PF7, PF8, PE4, PE3, PE2, PE1) to verify that they are still working. You can use a multimeter, use them to blink an LED or any method convenient for testing.

  2. If you are using an early release build then try using a stable version of the Arduino SDK - Version 4.0.9 and see if that helps with your project.

1 Like

— oh, thank you! Hardware SPI Success with ADS1256

I wanted to share a success story and solution for using Hardware SPI with external devices (ADS1256) on AMB82-MINI.

I was trying to connect ADS1256 (24-bit ADC) to AMB82-MINI but couldn’t get Hardware SPI to work. The test with SPI0 ↔ SPI1 (cross-connection) worked perfectly, but reading from ADS1256 always returned 0x00.

The key was using **`beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE1))` before `masterWrite()`**.

#include <SPI.h>
#define CS 10
#define PDWN 7
#define DRDY 9
void setup() {
Serial.begin(115200);
delay(1000);
pinMode(CS, OUTPUT);
pinMode(PDWN, OUTPUT);
pinMode(DRDY, INPUT);
digitalWrite(PDWN, HIGH);
digitalWrite(CS, HIGH);
SPI1.begin(SPI_MODE_MASTER);
delay(200);
SPI1.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE1));
digitalWrite(CS, LOW);
delayMicroseconds(5);
SPI1.masterWrite(0xFE);
delayMicroseconds(5);
digitalWrite(CS, HIGH);
SPI1.endTransaction();
delay(50);
SPI1.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE1));
digitalWrite(CS, LOW);
delayMicroseconds(5);
SPI1.masterWrite(0x10 | 0x00);
SPI1.masterWrite(0x04);
delayMicroseconds(10);
uint8_t status = SPI1.masterWrite(0xFF);
uint8_t mux = SPI1.masterWrite(0xFF);
uint8_t adcon = SPI1.masterWrite(0xFF);
uint8_t drate = SPI1.masterWrite(0xFF);
uint8_t io = SPI1.masterWrite(0xFF);
digitalWrite(CS, HIGH);
SPI1.endTransaction();
Serial.print(“STATUS=0x”); Serial.println(status, HEX);
Serial.print(“MUX =0x”); Serial.println(mux, HEX);
Serial.print(“ADCON =0x”); Serial.println(adcon, HEX);
Serial.print(“DRATE =0x”); Serial.println(drate, HEX);
Serial.print(“IO =0x”); Serial.println(io, HEX);
}
void loop() {
while (digitalRead(DRDY) == HIGH) {}
SPI1.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE1));
digitalWrite(CS, LOW);
delayMicroseconds(5);
SPI1.masterWrite(0x01);
delayMicroseconds(10);
uint8_t b0 = SPI1.masterWrite(0xFF);
uint8_t b1 = SPI1.masterWrite(0xFF);
uint8_t b2 = SPI1.masterWrite(0xFF);
digitalWrite(CS, HIGH);
SPI1.endTransaction();
int32_t raw = ((int32_t)b0 << 16) | ((int32_t)b1 << 8) | b2;
if (raw & 0x800000) raw |= 0xFF000000;
Serial.print("RAW: "); Serial.println(raw);
delay(500);
}

Pinout (SPI1):

ADS1256 → AMB82-MINI
DIN (MOSI) → PIN 2 (PF7, SPI1_MOSI)
DOUT (MISO) → PIN 0 (PF5, SPI1_MISO)
SCLK → PIN 1 (PF6, SPI1_SCLK)
CS → PIN 10 (GPIO)
PDWN (SYNC) → PIN 7 (GPIO, HIGH)
DRDY → PIN 9 (GPIO)
5V → 5V
GND → GND

What helps me:

  1. SPI1 (not SPI0) for external devices
  2. use `beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE1))` before `masterWrite()`
  3. Use `masterWrite()` (not `transfer()`) for communication
  4. Keep CS LOW during entire transaction
  5. Wait for DRDY = LOW before reading conversion data

Results:
SPI0 ↔ SPI1 cross-connection test: **Working** (masterRead: 0x44, slaveRead: 0x55)
ADS1256 register reading: **Working** (MUX=0x01, ADCON=0x20, DRATE=0xF0)
Reading conversion data from 4 channels:

LC1 (AIN0/AIN1): RAW=-1125 (0xFFFFFB9B)
LC2 (AIN2/AIN3): RAW=-165 (0xFFFFFF5B)
LC3 (AIN4/AIN5): RAW=-201 (0xFFFFFF37)
LC4 (AIN6/AIN7): RAW=3556 (0xDE4)

-–

LC1 (AIN0/AIN1): RAW=-1100 (0xFFFFFBB4)
LC2 (AIN2/AIN3): RAW=-190 (0xFFFFFF42)
LC3 (AIN4/AIN5): RAW=-189 (0xFFFFFF43)
LC4 (AIN6/AIN7): RAW=3518 (0xDBE)

-–

LC1 (AIN0/AIN1): RAW=-1087 (0xFFFFFBC1)
LC2 (AIN2/AIN3): RAW=-140 (0xFFFFFF74)
LC3 (AIN4/AIN5): RAW=-237 (0xFFFFFF13)
LC4 (AIN6/AIN7): RAW=3544 (0xDD8)

Special thanks to the forum moderator for the SPI0 ↔ SPI1 test example and quick support. The cross-connection test helped confirm that Hardware SPI works on AMB82-MINI, which led to finding the solution for external devices.

1 Like