Hi Friend,
My platform is SDK 16 with S140 softdevice.
I set a gpio for edge trigger interrupt. But I cannot get the correct gpio state if the data pulse is too short (maybe 4us to 20us). For example a 5us RF data rising edge generate an interrupt. I get low by my ISR use the function of nrf_gpio_pin_read(TDA5235A_PP1_PIN). Because the pulse is too short. The falling edge interrupt was generated before I read the port state. Like the picture. I have two questions. 1: How to know the interrupt is by falling edge or rising? 2: How to ignore the short pulse interrupt? (Does it can be set the debounce time of interrupt?)
My source code snippet:
uint32_t aaaa[100];
uint8_t bbbb[100];
uint8_t xxxx=0;
void tda5235_sample_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
int32_t counter;
uint8_t last_phrase;
if(lf_rf_task.items.rssi_valid == 1)
{
NRF_TIMER4->TASKS_CAPTURE[5] = 1;
counter = NRF_TIMER4->CC[5];
NRF_TIMER4->TASKS_CLEAR = 1;
if(xxxx<100)
{
aaaa[xxxx]=counter;
bbbb[xxxx]=0;
last_phrase = 1;
if(nrf_gpio_pin_read(TDA5235A_PP1_PIN))
{
bbbb[xxxx]=1;
last_phrase = 0; // current data bit = 1, so last phrase = 0
}
xxxx++;
}
....
}
/**
* @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
* and configures GPIOTE to give an interrupt on pin change.
*/
static void tda5235_gpio_init(void)
{
ret_code_t err_code;
....
nrf_gpio_cfg_input(TDA5235A_PP1_PIN, NRF_GPIO_PIN_PULLUP);
nrf_drv_gpiote_in_config_t in_config = {
.sense = NRF_GPIOTE_POLARITY_TOGGLE,
.pull = NRF_GPIO_PIN_PULLUP,
.is_watcher = false,
.hi_accuracy = true,
.skip_gpio_setup = false
};
err_code = nrf_drv_gpiote_in_init(TDA5235A_PP1_PIN, &in_config, tda5235_sample_handler);
APP_ERROR_CHECK(err_code);
}