This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can we change the SPI.bitOrder and SPI.dataMode while using nRF8001 BLE

Hi

I have a BLE module of nRF8001 chip and everything is working fine with it.In your Arduino compatible libraries for nRF 8001 you have a function hal_aci_tl_init() in which you set SPI for the chip. There you set SPI.setBitOrder(LSBFIRST) , SPI.setDataMode(SPI_MODE0) and clock speed.Now my question is can i change the bitOrder to MSBFIRST and DataMode to SPI_MODE1?

Actually i tried to do this this but BLE is not advertising then. How can i do this ,is there any way to use nRF8001 in MSBFIRST and SPI_MODE1?? I really need to do this because i am connecting a wifi shield also to my Arduino which again uses SPI pins for data transfer and that wifi shied works only on MSBFIRST and SPI_MODE1. How can i make nRF 8001 work on above specifications?

Thanks

  • nRF8001 will not operate on MSBIT first or at SPI mode 1, hower You should be able to share the SPI lines. in your case, you will need to set the SPI parameters for the WiFi when you want talk the to the WiFi SPI, when you want to talk to nRF8001 set the SPI parameters for nRF8001.

    You will have to use separate chip select lines and separate interrupt lines for the WiFi and the nRF8001. Only the MISO MOSI and SCK can be shared.

    As soon as you get a RDYN line low, set the nRF8001 SPI parameters for LSBIT and SPI MODE0 before you start the SPI. As soon as the nRF8001 SPI is finished you can set it back to the WiFi SPI settings of MSBIT and SPI MODE1

  • Actually i was thinking of doing this,but in my case i have to use them parallelly. Lets say, wifi get the response after hitting the server and i have to send that response to MCU which then have to be transmitted to the iPhone through BLE. this i can do by using the chip select that when response comes select the BLE chip for SPI linesand transfer. But suppose when wifi is using the SPI lines and iPhone want to connect through BLE and want to send some data then how will i know in MCU that i have to give the SPI lines to BLE and start advertising it? This is where i am stucking.Do you have any idea how to solve this?WHen wifi is using the spi lines then how to make ble advertising?

    Thanks

  • The nature of SPI is an SPI master can talk to only one Slave device at a time. However the nRF8001 does not have any real time requirements and you can access the SPI when you do have the time after the WiFi has finished the SPI access, this should be workable. If you do require simultaneous BLE and WiFi access on the SPI you can use 3 additional GPIOs on your mcu to implement a software based SPI master and then use the nRF8001 and WiFi on 2 different SPI masters on different pins.

  • Actually i am advertising BLE first then i start wifi shield which takes control over Spi pins and successfully ping the server tehn i disconnect wifi and then again when i try init the ble to make it advertising again it actually do niot advertise. What i think is Wifi shield does not remove its hold from spi pins, if it has removed hold then init function of ble will have set spi according to its use and would have started advertising. How can i solve this?

  • You may need to put an SPI.begin at the start of the SPI transaction and SPI.end in the end of the SPI transaction both for the nRF8001 and for the WiFi, you may also need to work with the WiFi library and documentation. We have verified that the nRF8001 can share the SPI with other devices but not with a WiFi device.

    The key point is that the WiFi should release the SPI lines when the chip select for the WiFi SPI is released. You need to verify this in a logic analyzaer.

Related