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

Trying to initiate SPI calls SystemReset

Hello,

I am currently trying to write my frist few lines of code.. I started with the ble_uart example and then mixed in some code from the spi_master example.. I wanted to try to communicate with a Sensor over SPI and to make sure it works, use UART.

But my code won't work and I haven't yet found out why. I will keep on searching but probably one of you could easily point out the problem.

It seems that after

/* Clear waiting interrupts and events */
    p_spi_instance->p_nrf_spi->EVENTS_READY = 0;

this is called:

NVIC_SystemReset

But I don't have a clue why.

Feel free to have a look at the attached main.c (Of course the uart_init call should be before my printfs.. but thats not the cause of the problem)

Parents
  • I set optimisation to the lowest possible level (0) and now the last line before the reset is:

    APP_ERROR_CHECK(sd_nvic_ClearPendingIRQ(p_spi_instance->irq_type));

    I searched and searched and looked into my code and finally I found this question here: devzone.nordicsemi.com/.../

    Looks like it has to be initialised AFTER ble_init. At least the ble_uart example part is working again now ;-)

  • I don't understand in what way the spi master and ble_init are related. And I read that other thread and it does state that the ble init must be called before setting up the spi master and I still don't understand why.

    spi master doesn't need BLE, BLE doesn't use the SPI master, they are unrelated. Quickly looking at the ble init I don't see what it would do to mess up a previously setup spi master nor what's required from ble init to make spi master work.

    Anyone care to shed light on WHY these two unrelated things have a dependency on each other?

Reply
  • I don't understand in what way the spi master and ble_init are related. And I read that other thread and it does state that the ble init must be called before setting up the spi master and I still don't understand why.

    spi master doesn't need BLE, BLE doesn't use the SPI master, they are unrelated. Quickly looking at the ble init I don't see what it would do to mess up a previously setup spi master nor what's required from ble init to make spi master work.

    Anyone care to shed light on WHY these two unrelated things have a dependency on each other?

Children
No Data
Related