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

nRF52810 + SD + SPIM

I'm having trouble using the NRFX SPIM driver on the NRF52810 w/ Softdevice (S112). (SDK15.0.0)

I'm able to initialize but when I go to use nrfx_spim_xfer without the callback it hangs. If I use the callback, it returns but eventually the application error handler fires with an unknown/weird error. 

(this one specifically)

<error> main:  id = 1, pc = 61386, file = KGJ`h??@h, line number: 536871936, error code = 1405 =  

It typically doesn't show up unless I actually step through. 

This one is definitely a head scratcher. I am using pin 21 for something else but both in the boot loader and the main app I removed the CONFIG_GPIO_AS_PINRESET define. (I've seen that sometimes pins with alternate functions may cause this error, for me no so much)

Actual code as follows:

// Initialize SPI_INSTANCE
nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
spi_config.mosi_pin = LED_SDI_PIN;
spi_config.sck_pin = LED_SCK_PIN;

err = nrfx_spim_init(&spi, &spi_config, NULL, NULL);
VERIFY_SUCCESS(err);

The transfer setup and execution looks like this

static uint8_t data[] = {0xaa, 0xaa};

nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TX(data, 2);

// Transfer test 16 bits
nrfx_spim_xfer(&spi, &xfer_desc, 0);

This has to be some weird cocktail of me setting something wrong or initializing something else that interferes with SPIM. Any thoughts are appreciated!

Parents
  • The error location is in softdevice, and "funny looking string" is probably just a NULL pointer.

    There might be problems in the SPIM interrupt handler - e.g. the handler function did not get picked up in "-flto" mode or an .o module (for the SPIM) is not linked properly.

    The default handler would cause a infinite looping in the handler function, which does not allow main() to run and thus cause a timeout in the softdevice.

    Another possible cause: Wrong interrupt priority. The default (0) priority is reserved by the softdevice.

  • Thanks

    I have "-flto" commented out as it's caused some similar issues in the past.

    I'll double check the priority, I haven't mucked with it but at this point it's likely to be something like that..

Reply Children
No Data
Related