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

LOCAL_ERR_CODE 0x00000018 on nrf_gpio_pin_clear in SPI Read Function

Hi, 

I'm using SES v4.52b, a nRF52832 module (BL652) and nRF5 SDK 16.0.0. I'm trying to build a generic SPI Read and Write functions with the following: 

int8_t spi_reg_read(uint8_t cs, uint8_t reg_addr, uint8_t *reg_data, uint8_t length)
{

    memset(reg_data, 0, length); //used to be 0xAA
    spi_xfer_done = false;

    uint8_t sizetx = 1; //sizeof(reg_addr);

    nrf_gpio_pin_clear(cs);

    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &reg_addr, sizetx, reg_data, length));

    while (!spi_xfer_done)
    {
	  __WFE();
    }

    nrf_gpio_pin_set(cs);

    NRF_LOG_INFO(" Received:");
    NRF_LOG_HEXDUMP_INFO(reg_data, sizeof(&reg_data));

    NRF_LOG_FLUSH();
}

The device I'm trying to control has two SPI slave buses and I'm using uint8_t cs to control which slave I'm talking to. I'm able to communicate once with the device and receive back the proper information in the register, but right after executing the nrf_gpio_pin_clear(cs); I get the LOCAL_ERR_CODE 0x00000018 in the expressions in SES. The second time I loop through the exact same register read, I don't get any value out (I don't have a scope available, but based on the err code I'm assuming that the nrf_gpio_pin_clear / set functions are failing after the first execution).  

<info> app: Transfer completed.
<info> app:  Received:
<info> app:  00 40 05 00            |.@.. 

Does anybody have any insight to why this err code would be happening?

Thanks!

Parents
  • Hello,

    Which pins are you using for the SPI transfer, and which pins are you using for your CS's?
    Are you using NRF_DRV_SPI_PIN_NOT_USED for the CS pin in your SPI config? The driver only supports controlling 1 CS by itself, and with multiple slaves this has to be done manually(which you are doing), but then the CS pin must be set to *_NOT USED. I think you might have done this, but I am just making sure.
    Could you also ensure that you have set "debug" build mode in SES(top left corner), and then run the program again?
    The contents of the generated APP error would be highly useful to have a look at.

    Looking forward to solving this issue together,

    Best regards,
    Karl

Reply
  • Hello,

    Which pins are you using for the SPI transfer, and which pins are you using for your CS's?
    Are you using NRF_DRV_SPI_PIN_NOT_USED for the CS pin in your SPI config? The driver only supports controlling 1 CS by itself, and with multiple slaves this has to be done manually(which you are doing), but then the CS pin must be set to *_NOT USED. I think you might have done this, but I am just making sure.
    Could you also ensure that you have set "debug" build mode in SES(top left corner), and then run the program again?
    The contents of the generated APP error would be highly useful to have a look at.

    Looking forward to solving this issue together,

    Best regards,
    Karl

Children
No Data
Related