GPIOTE events without interrupts

I have impulses coming to a GPIO input. Each pulse (say: rising edge) should toggle some other's GPIO output. What I know, is that I cat apply a task to a GPIO output. This task can toggle the output pin on each event automatically. There are many examples showing how to invoke GPIO task form timers or others peripherals. But I cannot find any information on: is it possible to invoke a task form GPIO event?

Unfortunately, invoking interrupt service is too slow in my case.

  • yes ppi does that. reading this and looking at the two sample code may help you.

  • Than you. Your advice solved my problem.

    The purpose was to setup I2S-master interface with output clock divided by two (to emulate 64-bit frame). The code below does the task usinhh Event-Task mechanism. It "captures" output pin signal (in) and outputs it in twice slower rate at another pin (out).

    void gpiote_init (int in, int out)
    {
        nrf_ppi_channel_t ppi_channel;
    
        int err_code = nrf_drv_ppi_init();
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_ppi_channel_alloc (&ppi_channel);
        APP_ERROR_CHECK(err_code);
    
        nrfx_gpiote_init();
    
        nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_HITOLO (true);
        in_config.is_watcher = true;
        err_code = nrfx_gpiote_in_init (in, &in_config, NULL);
        APP_ERROR_CHECK(err_code);
        nrfx_gpiote_in_event_enable (in, false);
    
        const nrfx_gpiote_out_config_t out_config = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE (false);
        err_code = nrfx_gpiote_out_init (out, &out_config);
        APP_ERROR_CHECK(err_code);
        nrfx_gpiote_out_task_enable (out);
    
        err_code = nrfx_ppi_channel_assign (ppi_channel,
                nrfx_gpiote_in_event_addr_get (in),
                nrfx_gpiote_out_task_addr_get (out));
        APP_ERROR_CHECK(err_code);
        err_code = nrfx_ppi_channel_enable (ppi_channel);
        APP_ERROR_CHECK(err_code);
    }

Related