# Problem setting registers (SPI) [NodeMCU fw, nRF24L01+]

I can read registers somewhat fine, but when I try writing to a register in the nRF24L01+, it either crashes and I have to pull it out of the board, or the register becomes all 0s, and I can't reset it back (so I have to pull it out to reset it)...

local buffer
local misolen = 64
local command = 0x06
local datalen = 8
local data = 0x0A

spi.setup ( 1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 80, spi.FULLDUPLEX )

for i = 0, misolen-1, 1 do

if ( i == 0 ) then
buffer = spi.get_miso ( 1, i, 1, 1 )
else
buffer = buffer .. spi.get_miso ( 1, i, 1, 1 )
end

if ( (i+1)%8 == 0 ) then
buffer = buffer .. ' '
end

end

print ( buffer )


It's probably a stupid thing, but it's my first time with SPI, and an nRF24L01+, and I don't have an oscilloscope, and I've been fiddling with this for two days now, and I'm out of switches and knobs to turn, so I turn to you...

Any help much appreciated,

• If the reading is working fine, the Phase and Polarity seems to be set properly. Are you sure you are complaint with the right protocol to start a write – Umar Aug 24 at 17:35
• @Umar The sheet says you can only set registers when the device is in power-down or standby modes, and reading register 0x00 returns that the device is in power-down mode. Then if I read register 0x03, I can see that the default TX/RX address size is 5 bytes, and if i try to set register 0x0B (RX_ADDR_P1) that can accept values from 0x0000000000 to 0xFFFFFFFFFF, so that should accept bits even if they're out of order or something, I still get a return status code of B00000000 and the nRF24 is dead, has to be disconnected to reset... I'm really at a loss... ;_; – poorandunlucky Aug 24 at 23:29