I've scraped through just about every DevZone post I could find related to this subject and none have indicated what the problem may be with my code. I'm using the nRF52840 DK to communicate via SPI with an ST7565 display driver. After successfully prototyping on an STM32, I attempted to port the code over to my Nordic DK and hooked up my pins to an oscilloscope to see what's going on -- every pin flatlines at 0V (except a GPIO I toggled on and off every 50ms as a control). I'd greatly appreciate any advice someone on here can provide, Zephyr has been a serious learning curve and I'd like to get over this hurdle so I can start working on developing my project. I'm using NCS 2.2.0 and Zephyr 0.15.2, host is Ubuntu 22.04. Application was built from zephyr/samples/hello_world. I'm using P0.19 and P0.20 (original pins) for SPI2 clock and MOSI.
TL;DR: SPI not working please help.
nrf52840dk_nrf52840.overlay:
&spi2 { status = "okay"; cs-gpios = < &gpio0 22 GPIO_ACTIVE_LOW >; }; &i2c0 { status = "disabled"; };
prj.conf:
CONFIG_GPIO=y CONFIG_SPI=y
main.c (removed irrelevant GPIO code):
#include <zephyr/kernel.h> #include <zephyr/drivers/spi.h> void st7565_comm(struct device *spi, const struct spi_config *spi_cfg, unsigned char data) { const struct spi_buf tx_buf = { .buf = &data, .len = 1 }; const struct spi_buf_set tx = { .buffers = &tx_buf, .count = 1, }; spi_write(spi, spi_cfg, &tx); } void main(void) { struct spi_config spi_cfg = {}; struct device *spi = DEVICE_DT_GET(DT_NODELABEL(spi2)); spi_cfg.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_OP_MODE_MASTER | SPI_HALF_DUPLEX; spi_cfg.frequency = 1000000U; st7565_comm(spi, &spi_cfg, 0xA0); }