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

Can't register more than two GPIOTE inputs

Hello all,

I currently have a test rig with 3 sensors, each with their own pin and interrupt they are supposed to carry out. Whichever two I put first in my gpiote_init() function will always work and setup properly while the third throws a NRF_ERROR_NO_MEM error. Here's code.

(NOTE: The only other pins I have setup are two PWM output pins which both function fine.)

void gpiote_init()
{
//printf("Enter gpiote_init");

uint32_t err_code;
if(!nrf_drv_gpiote_is_init())
{
	err_code = nrf_drv_gpiote_init();
	if (err_code != NRF_SUCCESS)
	{
		//printf("Error init GPIOTE Module");
	}
	else
	{
		//printf("SUCCESS init GPIOTE Module");
	}
}

#define HOME_PIN 25
#define MASS_PIN 28
#define DOSE_PIN 30

//sensor pin interrupt setup
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);

err_code = nrf_drv_gpiote_in_init(HOME_PIN, &config, sensor_home_interrupt);
if (err_code != NRF_SUCCESS)
{
	//printf("Error init sensor_home_interrupt");
}
nrf_drv_gpiote_in_event_enable(HOME_PIN, true);

err_code = nrf_drv_gpiote_in_init(MASS_PIN, &config, sensor_massage_interrupt);
if (err_code != NRF_SUCCESS)
{
	//printf("Error init sensor_massage_interrupt");
}
nrf_drv_gpiote_in_event_enable(MASS_PIN, true);

err_code = nrf_drv_gpiote_in_init(DOSE_PIN, &config, sensor_dose_interrupt);
if (err_code != NRF_SUCCESS)
{
	//printf("Error init sensor_dose_interrupt");
}
nrf_drv_gpiote_in_event_enable(DOSE_PIN, true);

NVIC_EnableIRQ(GPIOTE_IRQn);

return;
}

As you can see all three of my declarations are straight up copies of the ones found in the infocenter, why I am only capped at two is beyond me.

For the PWM init I use the app_pwm, I don't believe I am using GPIOTE channels for them, though I may be wrong. Heres the pwm_init.

int pwm_init()
{
ret_code_t err_code0;
ret_code_t err_code1;

/* 1-channel PWM, 2000Hz, output to LED1 and LED2 */
//100 = 1kHz, 200 = .5 kHz
app_pwm_config_t pwm0_cfg = APP_PWM_DEFAULT_CONFIG_1CH(50L, BSP_LED_0);
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(50L, BSP_LED_1);

/* Active High */
pwm0_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;

/* Initialize and enable PWM. */
err_code0 = app_pwm_init(&PWM0,&pwm0_cfg,pwm_ready_callback);
err_code1 = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code0);
APP_ERROR_CHECK(err_code1);    
	
return 0;
}
Parents Reply Children
No Data
Related