Use of nrfx_dppi with nrf5340 to control one GPIO

Dear,

I need to generate a pulse signal on one IO following this pattern:
HIGH for 12us ; LOW for 106us ;  and so on...


I tried to use TIMER0 with  NRF_TIMER_EVENT_COMPARE0 and NRF_TIMER_EVENT_COMPARE1 but the signal is often not respected (keeping one cycle the IO HIGH also during second period). So I assume I need to use dppi, but using the following code, I still not see anything happening on the io:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct gpio_dt_spec mofset_ctrl_io = GPIO_DT_SPEC_GET(DT_NODELABEL(mofset_ctrl), gpios);
#define TIMER_INSTANCE_NUMBER 0
const nrfx_timer_t timer_instance = NRFX_TIMER_INSTANCE(TIMER_INSTANCE_NUMBER);
#define TOGGLE_INTERVAL_ON_US 12
#define TOGGLE_INTERVAL_OFF_US 106
static nrfx_gpiote_t const gpiote_inst = NRFX_GPIOTE_INSTANCE(0);
static uint8_t dppi_channel;
static void timer0_init(void)
{
nrfx_err_t err;
nrfx_timer_config_t timer_config = NRFX_TIMER_DEFAULT_CONFIG(16000000);
timer_config.bit_width = NRF_TIMER_BIT_WIDTH_16;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Do you know why ? I confess it was difficult to setup this with all the API changes on that topic (add of nrfx_gpiote_t in prototypes and other changes), and I never found one full example working for nrf5340 and NCS 2.7.0 I am using.

Thanks in advance for your piece of advice!

Kind regards,

Michael