Baby steps for nRF52

The board has nRF52832 BLE micro controller chip and other relevant elements on it.

Here is the link for detailed description:
https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK

Several code development platforms are available for developers but I will show here only MBED platform. It is easy to use and easy to understand. UI is not crowded and it is running on browser. You can reach your code files anywhere in the world without loosing your any bit of information.

Quick start guide for nRF52 development kit by MBED platform:
https://os.mbed.com/platforms/Nordic-nRF52-DK/

One can easily modify given examples on above URL and start developing a new project. However two examples are not enough for many developers. If so, you can start searching on MBED github page for detailed examples.

Github page for MBED platform specialized for BLE:
https://github.com/ARMmbed/mbed-os-example-ble

SPI Communication Protocol for nRF52

I have started using this example project as a template and changed the pins according to this nRF52-DK pin names file.

#include "mbed.h"
SPI spi(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0); // mosi, miso, sclk
DigitalOut cs(SPI_PSELSS0);
 
int main() {
    // Chip must be deselected
    cs = 1;

    // Setup the spi for 8 bit data, high steady state clock,
    // second edge capture, with a 1MHz clock rate
    spi.format(8,3);
    spi.frequency(1000000);
 
    // Select the device by seting chip select low
    cs = 0;
 
    // Send 0x8f, the command to read the WHOAMI register
    spi.write(0x8F);
 
    // Send a dummy byte to receive the contents of the WHOAMI register
    int whoami = spi.write(0x00);
    printf("WHOAMI register = 0x%X\n", whoami);
 
    // Deselect the device
    cs = 1;
}

Without attaching any extra hardware the only answer you will get from serial monitor is oxFF.

Bir Cevap Yazın