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

SPI Master Error in sd_nvic_ClearPendingIRQ

I am using SDK 7.2 and Soft Device S110 7.1. I am also using the new version of nrf51 which has 32K RAM. I am not using the DK, but a custom board, though I see the same error on both.

I have a program that is attempting to start SPI Master to connect to some external FLASH. This is my main:

int main(void)
{
	simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, false);

	#ifdef SPI_MASTER_1_ENABLE
	sFLASH_Init();
    ....

All I am doing is setting up UART, then calling my function to initialize the FLASH. The function for sFLASH_Init() is:

void sFLASH_Init(void)
{
	spi_master_config_t spi_config = SPI_MASTER_INIT_DEFAULT;
	spi_config.SPI_Pin_SCK = SPIM1_SCK_PIN;
	spi_config.SPI_Pin_MISO = SPIM1_MISO_PIN;
	spi_config.SPI_Pin_MOSI = SPIM1_MOSI_PIN;
	spi_config.SPI_Pin_SS = SPIM1_SS_PIN;
	spi_config.SPI_CONFIG_ORDER = SPI_CONFIG_ORDER_MsbFirst;

	spi_master_open(SPI_MASTER_1, &spi_config);

So, basically, it just calls spi_master_open as the first item. I did redefine the pins, I am not using boards.h, they are:

#define SPIM1_SCK_PIN       24u     /**< SPI clock GPIO pin number. */
#define SPIM1_MOSI_PIN      23u     /**< SPI Master Out Slave In GPIO pin number. */
#define SPIM1_MISO_PIN      22u     /**< SPI Master In Slave Out GPIO pin number. */
#define SPIM1_SS_PIN        21u     /**< SPI Slave Select GPIO pin number. */

Anyway, in spi_master_open(), I am getting an error when sd_nvic_ClearPendingIRQ is called. I catch it in app_error_handler, this is the UART output I set up that I receive back:

Attempting to clear IRQ for type: 3
Hit a fault. Restarting.  
Error code: 2
In file:/Users/eely/libraries/nRF51_SDK_7.2.0_cf547b5/components/drivers_nrf/spi_master/spi_master.c
Line number: 332

Error Code 2, as far as I can tell, is NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED. When I debug, I see the same thing: image description

Why am I possibly getting this error? I am truly at a loss and have been banging my head against a wall trying to get simple SPI set up now for days. I tried to go back and load the spi_master_example, but I am having major issues getting examples to run properly with SDK7.2 (I am using Eclipse and GCC on OS X). I can't even get the example to run and instead see a hard fault in the line:

BLX R0

Of the gcc_startup_nrf51.S. I am not sure what is wrong there, but I cannot even get the simplest SPI example working with this hardware and SDK version.

PLEASE HELP!!!

Parents
  • Error 2 is also ... NRF_ERROR_SOFTDEVICE_NOT_ENABLED and I don't see anywhere in the code you posted where are actually enabling it.

    Yes it's annoying that the error codes overlap like that.

    btw. Don't really need the "PLEASE HELP!!!", anyone posting a question here is already asking for help.

  • If you're built against the softdevice (where 'built' in this case means the nrf_sof.h file imported is one of the softdevice ones as opposed to the no-softdevice one) then yes you need it enabled in order to call sd_nvic_* because the function makes a SVC call into the softdevice. The first thing that does in every case is check if the SD is enabled or not and fails with that error if it's not.

    If you are building to use without a softdevice, you can still use the SPI functions, just change your include path to have drivers_nrf/nrf_soc_nosd instead of softdevice/s110 (for instance) so you pick up the stub functions which don't call into the softdevice but just calls the underlying NVIC calls directly. If you're building for the softdevice then yes you need to at least enable it, even if you start no btle services.

Reply
  • If you're built against the softdevice (where 'built' in this case means the nrf_sof.h file imported is one of the softdevice ones as opposed to the no-softdevice one) then yes you need it enabled in order to call sd_nvic_* because the function makes a SVC call into the softdevice. The first thing that does in every case is check if the SD is enabled or not and fails with that error if it's not.

    If you are building to use without a softdevice, you can still use the SPI functions, just change your include path to have drivers_nrf/nrf_soc_nosd instead of softdevice/s110 (for instance) so you pick up the stub functions which don't call into the softdevice but just calls the underlying NVIC calls directly. If you're building for the softdevice then yes you need to at least enable it, even if you start no btle services.

Children
No Data
Related