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

Nrf51 Fast GPIOTE + Ble

Hi,

Im using S130softdevice.i wanna make dimmer by using experimental_ble_app_blinky project on gpioet But i have a problem with detecting 10 milisecond time (it means that i expect interrupt but it doesnt happen after each 10 milisecond)the lamb which i use flickers.

What can i do for gpioet to work better?

Thank You!

void GPIOTE_IRQHandler(void)
{

		 if(NRF_GPIOTE->EVENTS_PORT != 0)
    {
               
            NRF_GPIOTE->EVENTS_PORT= 0;
            nrf_delay_us(5000);	
		nrf_gpio_pin_set(16);
		nrf_delay_us(50);
		nrf_gpio_pin_clear( 16);
        
    }
		
}

static void gpiote_setup()
{
  uint32_t gpiote_event_addr;
  uint32_t gpiote_task_addr;
  ret_code_t err_code;

    // Initialise the button event GPIOTE
  nrf_drv_gpiote_in_config_t event_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);

  err_code = nrf_drv_gpiote_in_init(29, &event_config, button_handler);
  APP_ERROR_CHECK(err_code);

  gpiote_event_addr = nrf_drv_gpiote_in_event_addr_get(29);

  nrf_drv_gpiote_in_event_enable(29, true);

}
  • Hi,

    If your goal is to make a dimmer for a LED, I would recommend using PWM.

    Using the Low-power PWM library, this can be done something like in the code snippet below, and then you can set the LED brightness using the function low_power_pwm_duty_set().

    There is also a Low-Power PWM example in the SDK you can take a look at.

    static low_power_pwm_t low_power_pwm_0;
    
    static void pwm_init(void)
    {
        uint32_t err_code;
        low_power_pwm_config_t low_power_pwm_config;
    
        APP_TIMER_DEF(lpp_timer_0);
        low_power_pwm_config.active_high = false;
        low_power_pwm_config.period = UINT8_MAX;
        low_power_pwm_config.bit_mask = BSP_LED_2_MASK;
        low_power_pwm_config.p_timer_id = &lpp_timer_0;
    
        err_code = low_power_pwm_init((&low_power_pwm_0), &low_power_pwm_config, NULL);
        APP_ERROR_CHECK(err_code);
        
        err_code = low_power_pwm_duty_set(&low_power_pwm_0, 20);
        APP_ERROR_CHECK(err_code);
        err_code = low_power_pwm_start((&low_power_pwm_0), low_power_pwm_0.bit_mask);
    }
    
  • Im using AC LAMB. I need zero crossing therefore I want gpiote. Help me please.

  • What SDK are you using?

    GPIOTE_IRQHandler() is already implemented in nrf_drv_gpiote, and you should not modify it.

    You are calling button_handler() when pin 29 goes from low to high. What does button_handler do?

    If you want high priority for the GPIOTE, this can be done in SDK 12 by changing GPIOTE_CONFIG_IRQ_PRIORITY to 1(nRF51). If you are using SDK 11, set the priority to APP_IRQ_PRIORITY_HIGH in nrf_drv_config.h

Related