hello Nordic
i am working on nrf52840, SDK16.0 developing on the peripheral app_ble_blinky example.
i am use a pin as input interrupt from other device,
if i does all the init and enable (as shown in the first code below) before entering the main loop then i see i am getting in the interrupt handler, but if i try to do the same init or just the enable line after first part of init is done before main loop, then the interrupt handler doesnot get called, its like the interrupt is not enabled
void Accelerometer_init(void)
{
ret_code_t err_code = 0;
nrf_drv_spi_config_t accelo_spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
// comm timer ppi config:
// spi comm config:
accelo_spi_config.ss_pin = ACCELO_COMM_SPI_CS;
accelo_spi_config.miso_pin = ACCELO_COMM_SPI_MISO;
accelo_spi_config.mosi_pin = ACCELO_COMM_SPI_MOSI;
accelo_spi_config.sck_pin = ACCELO_COMM_SPI_CLK;
accelo_spi_config.frequency = NRF_SPI_FREQ_4M;
//accelo_spi_config.orc = 0x00;
err_code = nrf_drv_spi_init(&accelo_spi, &accelo_spi_config, accelo_spi_event_handler, NULL);
APP_ERROR_CHECK(err_code);
// nrf_gpio_pin_clear(DEBUG);
// config activity/free fall interrupt pin -> config in main
// config data ready pin input:
nrf_drv_gpiote_in_config_t int2_in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
int2_in_config.pull = NRF_GPIO_PIN_NOPULL;
err_code = nrf_drv_gpiote_in_init(ACCELO_INT2_SAMPLE_READY_INPUT_PIN_2, &int2_in_config, accelo_sample_ready_event_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(ACCELO_INT2_SAMPLE_READY_INPUT_PIN_2, true);
}
but if i call it like this:
void Accelerometer_init(void)
{
ret_code_t err_code = 0;
nrf_drv_spi_config_t accelo_spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
// comm timer ppi config:
// spi comm config:
accelo_spi_config.ss_pin = ACCELO_COMM_SPI_CS;
accelo_spi_config.miso_pin = ACCELO_COMM_SPI_MISO;
accelo_spi_config.mosi_pin = ACCELO_COMM_SPI_MOSI;
accelo_spi_config.sck_pin = ACCELO_COMM_SPI_CLK;
accelo_spi_config.frequency = NRF_SPI_FREQ_4M;
//accelo_spi_config.orc = 0x00;
err_code = nrf_drv_spi_init(&accelo_spi, &accelo_spi_config, accelo_spi_event_handler, NULL);
APP_ERROR_CHECK(err_code);
// nrf_gpio_pin_clear(DEBUG);
// config activity/free fall interrupt pin -> config in main
// config data ready pin input:
nrf_drv_gpiote_in_config_t int2_in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
int2_in_config.pull = NRF_GPIO_PIN_NOPULL;
err_code = nrf_drv_gpiote_in_init(ACCELO_INT2_SAMPLE_READY_INPUT_PIN_2, &int2_in_config, accelo_sample_ready_event_handler);
APP_ERROR_CHECK(err_code);
// nrf_drv_gpiote_in_event_enable(ACCELO_INT2_SAMPLE_READY_INPUT_PIN_2, true);
}
and somewhere in main loop i call this:
nrf_drv_gpiote_in_event_enable(ACCELO_INT2_SAMPLE_READY_INPUT_PIN_2, true);
after words i will call disable and then enable again since this interrupt should not be handled at all time of the program
any idea why?
i also left the spi in the init cause i saw on the forum that there maybe some priority issues but i am not sure it is relevant to my case cause if the init of the interrupt is done in the raise of the program it works
hope to read from you soon
best regards
Ziv