Hello,
i'm trying to use SPI with nrf9160DK as master and RFM96 module as slave. At the moment, i'm developing elementary functions to write and read from my slave device. RFM9X module needs the following settings:
Word size: 8bit, CPOL=0, CPHA=0, Max SPI bus Frequency = 10MHz, CS Active Low, MSB first
The SPI timing sequence for a standard single access is the following:
The MSb of the address byte needs to be 1 if i'm writing, 0 if i'm reading the register.
The pin used in this test are placed in overlay file:
I used VDD=3V using SW11 of the nrf9160DK. I verified that SPI is generally working using a loopback test. I verified all the connections from the slave side.
This is the code i developed:
With this code i'm unable to get any consistent answer from my slave device (i noticed that i get always 8 or 0 if the address i use is even/odd...doesn't make any sense). This is a first bunch of fast questions about SPI:
- Is the spi config structure correctly set or i missed anything? In particular i want to be sure that i understood CPOL and CPHA setting;
- What about the "slave" element of spi config structure? I have 1 slave so i suppose i had to set it to 1, but is it really necessary?
- I'm having hard time getting a full grasp about "spi_buf" and "spi_buf_set" structure. While is intuitive understanding why "spi_buf" is structured like this, i don't understand why "spi_buf_set" has a "count" element. Why should i set an array or spi_buf struct?
- Is, in general, the flow described in the above picture reproduced by my code or i am missing anything?
Thanks,
Frax