# BW16 Development board SPI\_Slave,Master help

**URL:** https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179
**Category:** Peripherals
**Tags:** rtl872xd, evb-bw16
**Created:** [April 6, 2022, 10:17am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179 "2022-04-06T10:17:06Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![eckim](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@eckim](https://forum.amebaiot.com/u/eckim)
#### Post date: [April 6, 2022, 10:17am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/1 "2022-04-06T10:17:06Z")

</div>

Hello, I am doing SPI communication with a BW16 development board, and I want to use two Bw16 development boards, one as a Master and the other as a Slave. I’m developing with the Arduino IDE, and I’m having trouble with the Slave part, so I’m asking for help.

1. When BW16 uses SPI, can it be used only for master purpose?

2. Data can be transmitted using SPI.transfer(), but how does the slave receive data?

3. If there is an example of Master-Slave SPI communication Arduino IDE, please share.

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [April 7, 2022, 2:16am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/2 "2022-04-07T02:16:10Z")

</div>

Hi, @eckim

If you are using BW16 – RTL8720DN, then please note that there is only 1 set of SPI which is `SPI1`, and it only support Master mode, not slave mode

> [@eckim](#):
>
> Data can be transmitted using SPI.transfer(), but how does the slave receive data?

SPI is a bi-directional communication protocol, but only master initiate the transfer, slave only receive and transfer back information upon master’s request

> [@eckim](#):
>
> If there is an example of Master-Slave SPI communication Arduino IDE, please share.

There are plenty on the internet, for example

> **[How to use SPI (Serial Peripheral Interface) in Arduino to Communication...](https://circuitdigest.com/microcontroller-projects/arduino-spi-communication-tutorial)**
>
> In this tutorial we use SPI Protocol for communication between two Arduinos. Here one Arduino will act as Master and another one will act as Slave, two LEDs and push buttons will be connected to both the arduinos.

---

<div class="post-metadata">

### Author: ![eckim](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@eckim](https://forum.amebaiot.com/u/eckim)
#### Post date: [April 11, 2022, 5:15am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/3 "2022-04-11T05:15:00Z")

</div>

Thank you for good information.

You said that BW16 supports SPI1 and does not support slave mode.

However, as shown in the figure below, ‘RTL8720DN’ is  
It supports ‘HS\_USI\_SPI’ function and supports Master/Slave mode.  
‘BW16’ based on ‘RTL8720DN’ can’t use that function?

 ![ddd](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/969cc2a15b540f88936b3e93ed7a91963ae88cf7.png)

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [April 11, 2022, 5:41am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/4 "2022-04-11T05:41:54Z")

</div>

Hi

BW16 dosen’t have `HS_USI_SPI` peripheral, it only has `HS_SPI1` which only support master mode as shown in your picture

---

<div class="post-metadata">

### Author: ![eckim](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@eckim](https://forum.amebaiot.com/u/eckim)
#### Post date: [April 11, 2022, 6:11am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/5 "2022-04-11T06:11:06Z")

</div>

Thank you very much.

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [April 11, 2022, 6:12am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/6 "2022-04-11T06:12:35Z")

</div>

If you can get the IC, maybe you can make use of the USI\_SPI, but on the BW16 module itself, it doesn’t have

---

<div class="post-metadata">

### Author: ![eckim](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@eckim](https://forum.amebaiot.com/u/eckim)
#### Post date: [April 11, 2022, 6:15am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/7 "2022-04-11T06:15:18Z")

</div>

If I get an IC, if I want to use USI\_SPI, how should I connect it to the IC to operate as a slave?

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [April 11, 2022, 6:27am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/8 "2022-04-11T06:27:22Z")

</div>

you need to check which are the pins for `HS_USI_SPI`, then configure these pins accordingly in the software, the rest is the same as using normal hardware SPI

---

<div class="post-metadata">

### Author: ![Smythbuilt](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Smythbuilt](https://forum.amebaiot.com/u/Smythbuilt)
#### Post date: [May 10, 2022, 5:09am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/9 "2022-05-10T05:09:41Z")

</div>

USI SPI can work as slave on BW16, but the CS pin is not exposed on an external pin. It is instead connected to ground internally via a pull down.

You can use a different pin for CS with an interrupt, and in the interrupt flush any received data and start a new Receive.

However, this would not allow more than one slave device on the bus. Its also not very fast, needing the master to have some delays after changing the CS state, to allow the slave to be ready.

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [May 10, 2022, 5:52am UTC](https://forum.amebaiot.com/t/bw16-development-board-spi-slave-master-help/1179/10 "2022-05-10T05:52:39Z")

</div>

Hi @Smythbuilt

Thanks for sharing your findings~
