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

SPI Packet

I want to use ATMEGA 328 to send a packet over to the chip as follows:

SPDR = packet ;

Can some one kindly post what the content of this packat should be ? is it possible to transfer a 32 Byte packet in this way to the BLE chip ?

Thanks in advance for you support. Any sample application code for this would be much appriciated.

Parents
  • Hi,

    If you want to interface with the nRF8001, you may want to have a look in the nRF8001 spec. Chapter 7 Interfaces, and from chapter 18 to 27 are important to know how it works (how to interface your MCU with nRF8001).

    It's actually good idea to follow what we do in the Arduino SDK as Awneil pointed out.

    We also provided the SDK for nRF8001 but using our own MCU (nRF8200). It may not as similar to Atmel chip as the Arduino

  • I think I have figured out the send packet:

    COMMAND PART:

    For example you want to read Temp: (this works in every mode)

    The SPI transmission should consist of 2 bytes: Lenght and Command.

    SS Pulled low. Wait for handshake : RDYN gets pulled low. SPDR = 0X01; wait for transmission to complet. SPDC = 0X0C; wait for transmission to complete.

    SS Pulled up. RDYN goes back up. Transmission complete.

    EVENT PART (Response from the nRF8001):

    RDNY gets pulled low, trigger interrupt and pully SS low. Then start sending some kind of dummy bits (dont know what this should be) to the nRF8001 to get the SPI transmission from the nRF:

    The resulting read on the SPDR after every dummy transmit should look as follows:

    Byte 0: Debug Byte (dont know what this is) Byte 1: 0X04 (legnth of packet in numer of bytes (excluding this byte) and byte 0) Byte 2: 0X84 (Event Type : command response) Byte 3: 0x0C (Temp Read command) Byte 4: 0x00 (success status) Byte 5: 0X0A ( value to be div by 4, i.e. this reads 2.5°C)

    As you can see there are still some gaps in my unerstanding of the "Event" part of the communication. May be there is some expert out there who has figured this out much better than me.

    Regards

    However the "event packet" has a "debug byte" in the header of the packet, which gets discarded. Does any one know what this is ?

    Does this "debug byte" get generated every time even when the connection is successful.

Reply
  • I think I have figured out the send packet:

    COMMAND PART:

    For example you want to read Temp: (this works in every mode)

    The SPI transmission should consist of 2 bytes: Lenght and Command.

    SS Pulled low. Wait for handshake : RDYN gets pulled low. SPDR = 0X01; wait for transmission to complet. SPDC = 0X0C; wait for transmission to complete.

    SS Pulled up. RDYN goes back up. Transmission complete.

    EVENT PART (Response from the nRF8001):

    RDNY gets pulled low, trigger interrupt and pully SS low. Then start sending some kind of dummy bits (dont know what this should be) to the nRF8001 to get the SPI transmission from the nRF:

    The resulting read on the SPDR after every dummy transmit should look as follows:

    Byte 0: Debug Byte (dont know what this is) Byte 1: 0X04 (legnth of packet in numer of bytes (excluding this byte) and byte 0) Byte 2: 0X84 (Event Type : command response) Byte 3: 0x0C (Temp Read command) Byte 4: 0x00 (success status) Byte 5: 0X0A ( value to be div by 4, i.e. this reads 2.5°C)

    As you can see there are still some gaps in my unerstanding of the "Event" part of the communication. May be there is some expert out there who has figured this out much better than me.

    Regards

    However the "event packet" has a "debug byte" in the header of the packet, which gets discarded. Does any one know what this is ?

    Does this "debug byte" get generated every time even when the connection is successful.

Children
No Data
Related