I am trying to implement IR reception using TSOP1738, more specifically Vishay's SM0038.
I have set the GPIO pin to call an interrupt whenever there is any change in the GPIO pin. The problem is that, the TSOP generates some random pulse and so, the interrupts gets called, even if there is no IR signal. I tried changing TSOP, but still the TSOP generate some random pulse. The DK is connected to PC via USB, and power is taken from the PC. When I try to connect the DK to power bank, the rate of interrupt call is getting reduced considerably.
I have connected the TSOP directly to the GPIO pin, without any capacitor or resistor added to the circuit.
So the problem is the TSOP generates random pulses. How can I solve it?
Here is the code I've written. Can I make the interrupt sensitive to some range of voltage change?
void tsop_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
printf("\ntsop pin handler working\n");
}
static void gpiote_init(uint32_t tsop_pin)
{
uint32_t gpiote_event_addr;
if(!nrf_drv_gpiote_is_init())
{
err_code = nrf_drv_gpiote_init();
}
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(tsop_pin, &config, tsop_pin_handler);
nrf_drv_gpiote_in_event_enable(tsop_pin, true);
}
Please help