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!!!

Related