# SPI Hifive 1 Rev B

**URL:** <https://forums.sifive.com/t/spi-hifive-1-rev-b/2666>\
**Category:** HiFive1 Rev B\
**Created:** [July 24, 2019, 6:10am UTC](https://forums.sifive.com/t/spi-hifive-1-rev-b/2666 "2019-07-24T06:10:09Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![Kjarvel](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@Kjarvel](https://forums.sifive.com/u/Kjarvel)\
**Post date:** [December 3, 2019, 10:29pm UTC](https://forums.sifive.com/t/spi-hifive-1-rev-b/2666/23 "2019-12-03T22:29:59Z")

</div>

I created a HiFive1 Rev B WiFi example here: [https://github.com/kjarvel/hifive1revb\_wifi](https://github.com/kjarvel/hifive1revb_wifi)

Note:

- The code is generic C, using the registers from the [Freedom E310-G002 Manual](https://www.sifive.com/boards/hifive1-rev-b), not using the metal library.
- The modules are sort of stand-alone, include `cpu.h` or `uart.h` to use them (except `spi.c` that requires all the others).
- The code is sort of test code with no error handling, just to be simple (please be kind 😉 ).

The application enables 320 Mhz clock speed for the CPU, and 115200 bps for UART.  
SPI1 communication speed is set to 80 kHz (can be changed).

Connect to the UART using for example Tera Term or PuTTY, enter the SSID and password of the AP you want to connect to, see the screenshot here:  
(Press the reset button on the board until you see the initial `AT+CWMODE=0-->OK` message).

 ![Hifive1RevB_wifi_log](https://us1.discourse-cdn.com/flex020/uploads/sifive/original/1X/1129f417c641dcdc0e74b8ee2f3d0bb596ff6991.png)

After disconnecting, you can enter extra AT commands.

To get this working:

- Thanks to @Disasm for all the helpful hints!
- I used a logic analyzer to get this to work, looking at the `AT+CWMODE=0` commands sent by the default firmware (hifive\_revb\_bootloader).
- The trick was to enable SPI1\_CSMODE = CS\_AUTO and SPI1\_CSID = 2 to get the CS pin high / low.
- Listening on the Handshake pin was also important…
- Note that the code ignores any replies from the ESP32 (and does not ask for replies).

---

_[View the full topic](https://forums.sifive.com/t/spi-hifive-1-rev-b/2666)._
