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

NRF_PWM(For LED) and Button Interrupt Clash

Hello,

i am working with nrf_pwm library which is there in git. Also, on my device, with PTR51822, S110 7v is running. I am having tri color led on the device, by using pwm lib i am able to generate RGB colors. But after having done that the Button pin change interrupt is not reflecting.

What arrangement i am having:

  • When button is pressed, send a random character over nus_ble.(this i am carrying out from main context by setting flag)

  • Tri color led to light up color when some pattern of character i receive over nus_ble.()

  • What happening is:

  • If i light up some color first then button interrupt not works.

  • If i first press button, then button interrupt works, then i glow LED then it glows, after that if i again press button, the button interrupt does not works!

  • Desire:

  • Want tri color LED which occupies three gpio of nrf51822/ptr51822, and one button to work together!

Some of my codes goes here: Button related:

static void button_int_Init( void ){
	
	nrf_gpio_cfg_input( TACT, NRF_GPIO_PIN_PULLDOWN );
	
	NRF_GPIOTE->INTENSET  = GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos;
	
	
	nrf_gpiote_unconfig( 0 );
	nrf_gpiote_event_config( 0, TACT, NRF_GPIOTE_POLARITY_LOTOHI);
	sd_nvic_SetPriority( GPIOTE_IRQn, 1 );
	sd_nvic_EnableIRQ( GPIOTE_IRQn );
	
}

void GPIOTE_IRQHandler(void)
{
    // Event causing the interrupt must be cleared.
    if ((NRF_GPIOTE->EVENTS_IN[0] == 1) && 
        (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN0_Msk))
    {
        NRF_GPIOTE->EVENTS_IN[0] = 0;
    }
	
	buttonPressEventHappended = true;
		
}

My Main context:

 // Initialize
	// Some var init code goes here...
	nDataOffset = 0;
	n_rgb_b_weight = n_rgb_g_weight = n_rgb_r_weight = 0;
	
	//
	
    leds_init();
	peripheral_init();
    timers_init();
    buttons_init();
        
    ble_stack_init();
    scheduler_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    sec_params_init();
    
    button_int_Init();
	initAdxl() ;

	pwm_led_set_config( PWM_MODE_LED_255 );// With SoftDevice Enabled 1
    advertising_start();
  • you can check out the body of nrf_pwm_init() , pwm_led_set_config() and nrf_pwm_set_value() from the github here.

  • my button is on 26, which is named as TACT in the code.

What could be the solution so i could make led and button work together? Or any way out so make button and some legs of LED work together with less PWM ?

Parents Reply Children
No Data
Related