This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with nrf51822 in spi slave mode

Hello all

I making some device with ARM core CPU with nRF51822.

I set CPU to SPI master and set nRF51822 to slave. And then I read some data from nRF51822, that was always "0x55" or "0xAA". That depend on configuration of POL and PHA in master side.

Do you guess what is wrong?

B. Regards,

Parents
  • Hi Sean

    I assume you are using the spi_slave_example from nRF51 SDK v6.0.0?

    The character 0x55 is the ORC character (SPI over-read character). The character 0xAA is the DEF character (SPI default character) You can read about what those characters stand for in the SPIS section in the nRF51 Series Reference manual. I do not realize however why they are clocked out on MISO in this case.

    The most common problem however when interfacing the nRF51 SPIS is that there needs to be a 7.1us delay from when you set CSN high until you start clocking out data, see nRF51822 PS v2.0, table 39.

    Make sure your POL and PHA settings are identical on SPI master and SPI slave side. To configure that on the nrf51 slave, you need to write to the SPIS->CONFIG register. To do that in the spi_slave_example from nRF51 SDK v6.0.0, you select the SPI mode. By default, the example sets the SPIS to mode 0 (see the spi_slave_example_init function), which contains the configuration (CPOL = 0, CPHA = 0). The total mapping is:

    SPI_MODE_0,                             /**< (CPOL = 0, CPHA = 0). */
    SPI_MODE_1,                             /**< (CPOL = 0, CPHA = 1). */
    SPI_MODE_2,                             /**< (CPOL = 1, CPHA = 0). */
    SPI_MODE_3                              /**< (CPOL = 1, CPHA = 1). */
    

    as defined in spi.slave.h. So, select the mode that reflects the POL and PHA settings of the SPI master device.

    If the above does not help, it would be helpful to see all the signals on the SPI bus, i.e. the CSN, SCK, MOSI and MISO

  • To get the nRF51 Series reference manual, the easiest way is to create a profile on www.nordicsemi.com and then download it directly from our web site at www.nordicsemi.com/.../20337 You can also get the nRF51822 PS on this path www.nordicsemi.com/.../20339 However, you apply the 7.1us delay on the SPI master device, set the CSN high, wait for minimum 7.1us and then start clock out data. Is that possible on your SPI master device?

Reply Children
No Data
Related