0
\$\begingroup\$

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 address = 0xE7E7E7E7E7
local addrlen = 5
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 )

spi.transaction ( 1, 8, command, addrlen*8, address, datalen, 0, misolen )

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,

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – Umar Aug 24 at 17:35
  • \$\begingroup\$ @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... ;_; \$\endgroup\$ – poorandunlucky Aug 24 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.