Test platform: nRF54L15-DK
NRF Connect 2.9.0
When calling spi_write_dt, under the hood spi_nrfx_spim.c > configure is called to prepare the SPIM interface for a transmission.
The following line in spi_nrfx_spim.c > configure produces a hard fault:
nrfy_gpio_pin_write(nrfy_spim_sck_pin_get(dev_config->spim.p_reg), spi_cfg->operation & SPI_MODE_CPOL ? 1 : 0);
nrfy_spim_sck_pin_get queries the harware SPIM device for the CLK pin.
If no CLK pin is configured, UINT_MAX is returned.
nrfy_gpio_pin_write sets the pin to the correct level for the pending transmission.
However, if no CLK pin is configured, nrfy_pio_pin_write will try to set pin 4294967295, which results in a fault.
Solution: Check if the CLK pin is valid before setting it.
uint32_t sck_pin = nrfy_spim_sck_pin_get(dev_config->spim.p_reg); if (sck_pin != UINT_MAX) { nrfy_gpio_pin_write(sck_pin, spi_cfg->operation & SPI_MODE_CPOL ? 1 : 0); }
Background:
The WS2812 LED driver uses the SPI interface for a 1 wire serial interface.
To use this 1-wire interface, only MOSI is required, the CLK pin can be left unconnected.