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

Softdevice and interrupt lost

Hi everyone, My configuration:

  • nrf52832 microcontroller
  • Softdevice S132 V4.0.2
  • Nordic SDK 13.0
  • IDE: Eclipse

I'm working with a "Stand-alone can bus controller" connected to nrf52832 with SPI interface. The CAN controller informs nrf52 micro, via an interrupt pin, that a “CAN packet" was received on the stand-alone controller. I analyzed that interrupt events are very frequent (about 500us). Interrupt pin is configured as input interrupt pin using GPIOTE:

void can_controller_interrupt_pin_init(uint8_t pin_int)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;

    err_code = nrf_drv_gpiote_in_init(pin_int, &in_config, can_controller_int_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(pin_int, true); 
}

My problem is:

  • During BT advertising, interrupt requests coming from CAN controller, are correctly detected.
  • During BT connection, interrupt requests coming from CAN controller, are discarded.

It seems that Softdevice gives high priority to BLE connection and ignore interrupts.

How can I resolve this problem, without using a "polling solution"?

GATT Configuration:

#define APP_ADV_INTERVAL                64                                      /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS      360                                     /**< The advertising timeout (in units of seconds). */

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(15, UNIT_1_25_MS)         /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)         /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY                   0                                       /**< Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(6000, UNIT_10_MS)         /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                   /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                  /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                       /**< Number of attempts before giving up the connection parameter negotiation. */

SPI Configuration:

ret_code_t spi1_init(void)
{
	ret_code_t err_code;

	nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;

	/* SPI Parameters */
	spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
	spi_config.miso_pin = SPIM1_MISO_PIN;
	spi_config.mosi_pin = SPIM1_MOSI_PIN;
	spi_config.sck_pin  = SPIM1_SCK_PIN;
	spi_config.orc  	= 0x00;						
	spi_config.frequency = NRF_DRV_SPI_FREQ_4M;		
	spi_config.mode      = NRF_DRV_SPI_MODE_0;
	spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;

	m_spi1.m_spi_instance = spi1;
	m_spi1.m_spi_xfer_done = true;					

	/* Function for initializing the SPI master driver instance. */
	err_code = nrf_drv_spi_init(&spi1, 			
								&spi_config,    
								spi1_event_handler,
								NULL);

	m_spi1.m_init = (err_code == (NRF_SUCCESS)||NRF_ERROR_INVALID_STATE)? true : false;

	return err_code;
}

Interrupt routine:

void can_controller_int_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	flag_can_msg = true;
}

Many thanks!

Parents Reply
  • ok, this typically means the interrupt routing is working ok with the softdevice enabled (since it is advertising), need to look at other issues in the code that is preventing the interrupt from running. Can you set up a gpio toggle in the interrupt code on the logic analyzer and also the hardware pin that is interrupting the mcu, i.e. and post some results. Make sure that the volatile has not been optimized out in your build, try changes in the optimization level or look at the generated code to verify that volatile is still present.

Children
No Data
Related