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

What is maximum GPIOTE Peripheral clock frequency for Interrupts? [Without PPI] nrf52832

I'm not using softdevice, What is maximum GPIOTE Peripheral clock frequency for Interrupts for nrf52832? [Without PPI] 

Thanks

  • Here is the difference between polling and ISR.. polling is working much better.. What's wrong???

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf.h"
    #include "nrf_drv_timer.h"
    #include "nrf_drv_clock.h"
    #include "nrf_drv_gpiote.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "boards.h"
    #include "app_error.h"
    
    #define PIN_TO_TOGGLE 27
    #define PIN_TO_TOGGLE2 28
    #define PIN_SCL 25
    
    //#define USE_INTERRUPTS
    
    #ifdef USE_INTERRUPTS
    void in_pin_scl_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        
    
        if(nrf_drv_gpiote_in_is_set(PIN_SCL))
            nrf_gpio_pin_set(PIN_TO_TOGGLE2);
        else
            nrf_gpio_pin_clear(PIN_TO_TOGGLE2);
    
    }
    #endif
    
    
    static void hfclk_config(void) {
        ret_code_t err_code = nrf_drv_clock_init();
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_clock_hfclk_request(NULL);
    }
    
    
    int main(void)
    {
        hfclk_config();   
        
        ret_code_t err_code;
        if(!nrf_drv_gpiote_is_init())
        {
            err_code = nrf_drv_gpiote_init();
            APP_ERROR_CHECK(err_code);
        }
    
        #ifdef USE_INTERRUPTS
        nrf_drv_gpiote_in_config_t in_config2 = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
        in_config2.pull = NRF_GPIO_PIN_PULLUP;
    
        err_code = nrf_drv_gpiote_in_init(PIN_SCL, &in_config2, in_pin_scl_handler);
        APP_ERROR_CHECK(err_code);
        
        nrf_drv_gpiote_in_event_enable(PIN_SCL, true);
        #else
        nrf_gpio_cfg_input(PIN_SCL,NRF_GPIO_PIN_PULLUP);
        #endif
        
        nrf_gpio_cfg_output(PIN_TO_TOGGLE);
        nrf_gpio_cfg_output(PIN_TO_TOGGLE2);
    
        while (1)
        {
            #ifndef USE_INTERRUPTS
            if(nrf_drv_gpiote_in_is_set(PIN_SCL))
                nrf_gpio_pin_set(PIN_TO_TOGGLE);
            else
                nrf_gpio_pin_clear(PIN_TO_TOGGLE);
            #endif
        }
        
       
    }
    
    /** @} */
    

  • Hi,

    this is quite expected - in polling mode, CPU needs to execute one port read, compare and one port write in a loop. In interrupt mode, there is an overhead of interrupt handler (take a look at nrfx_gpiote_irq_handler in SDK\modules\nrfx\drivers\src\nrfx_gpiote.c to see amount of code executed at each interrupt occurence). The advantage of interrupt mode is that you can do other tasks or put CPU to sleep while waiting for pin change, but polling will be faster in any case.

Related