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

SPI initialization for communicating with the sensor

I am using a custom board based on nRF52 (nRF52832-QFAB-R). I am using the ble_hid_mouse app and performing the initialization for SPI in the main routine. But with the SPI initialization code enabled the device stops even advertising whereas with SPI initialization code disabled the device does advertise. I am performing the gpiote initialization for max user 5 using the macro before SPI init. Can you please suggest what may be going wrong here? How to debug?

Thanks

  • Hey Alok,

    We need more information. "with the SPI initialization code enabled the device stops even advertising", what do you mean by stops advertising, does your softdevice calls return any error message?

    Cheers,

    Håkon.

  • Hi Håkon,

    While performing the initialization for the SPI, I am configuring a pin in order to monitor the motion events from the sensor over SPI using the routine : nrf_gpio_cfg_input(pin num, NRF_GPIO_PIN_NOPULL). After this I am registering a gpiote user/handler for the same using the call to app_gpiote_user_register() routine.

    On debugging, it is found that the app_gpiote_user_register() routine returns the ERROR code 4(No Memory).

    Just to inform that I am not doing APP_GPIOTE_INIT(MAX_USERS) or app_gpio_init() before this anywhere in the code currently but I have already tested by performing the above initialization also with same result.

    Thanks

  • Any input on why the app_gpiote_user_register() routine returns the ERROR code? Is it required to perform APP_GPIOTE_INIT(MAX_USERS)  before registering the user (though the result is same for me even if done this way)?

    Result is same by performing the same in following way :

    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

    nrf_drv_gpiote_in_config_t gpiote_in_config;
    gpiote_in_config.is_watcher = val;
    gpiote_in_config.hi_accuracy = val;
    gpiote_in_config.pull = val;
    gpiote_in_config.sense = val;

    err_code = nrf_drv_gpiote_in_init(Pin, &gpiote_in_config, gpiote_evt_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_gpiote_in_event_enable(Pin, true);

  • Hi Håkon,

    I am still not able to resolve this issue. Can you please let me know if some pointers on this?

    Thanks.

  • What is the size of MAX_USER?

    You do not need to initialize the driver or pass it configs when using the app_gpiote library.

    Steps to use the library:

    1. APP_GPIOTE_INIT()
    2. app_gpiote_user_register()
    3. app_gpiote_user_enable()

    See SDK14.2/components/libraries/gpiote/app_gpiote.h for more information

Related