Hi,
I'm trying to use 2 GPIOTE channels, 3 PPI channels, and a Timer instance in an application.
The 1st GPIOTE channel is input where it should trigger the Timer instance to start through PPI channel, at the same time I configured the "Timer compare event" to toggle the 2nd GPIOTE channel through PPI, and I configured the last PPI channel to stop the timer by its "compare event".
The channel configurations are as follows:
status = nrfx_gppi_channel_alloc(&gppi_channel);
NRFX_ASSERT(status == NRFX_SUCCESS);
status = nrfx_gppi_channel_alloc(&gppi_channel_1);
NRFX_ASSERT(status == NRFX_SUCCESS);
status = nrfx_gppi_channel_alloc(&gppi_channel_2);
NRFX_ASSERT(status == NRFX_SUCCESS);
/*
* Configure endpoints of the channel so that the input timer event is connected with the output
* pin OUT task. This means that each time the timer interrupt occurs, the LED pin will be toggled.
*/
nrfx_gppi_channel_endpoints_setup(gppi_channel,
nrfx_timer_compare_event_address_get(&timer_inst, NRF_TIMER_CC_CHANNEL0),
nrfx_gpiote_out_task_addr_get(OUTPUT_PIN));
nrfx_gppi_channels_enable(BIT(gppi_channel));
nrfx_gppi_channel_endpoints_setup(gppi_channel_1,
nrfx_gpiote_in_event_addr_get(INPUT_PIN),
nrfx_timer_task_address_get(&timer_inst, NRF_TIMER_TASK_START));
nrfx_gppi_channels_enable(BIT(gppi_channel_1));
nrfx_gppi_channel_endpoints_setup(gppi_channel_2,
nrfx_timer_compare_event_address_get(&timer_inst, NRF_TIMER_CC_CHANNEL0),
nrfx_timer_task_address_get(&timer_inst, NRF_TIMER_TASK_STOP));
nrfx_gppi_channels_enable(BIT(gppi_channel_2));
But what happens is that the input pin trigger the timer to start and the timer stops itself but the output pin isn't changing.
The response from the DK:
[00:00:00.422,607] <inf> NRFX_EXAMPLE: Starting nrfx_gppi basic one-to-one example. [00:00:00.430,694] <inf> NRFX_EXAMPLE: GPIOTE status: initialized [00:00:00.430,725] <inf> NRFX_EXAMPLE: Time to wait: 1000 ms [00:00:06.158,020] <inf> NRFX_EXAMPLE: GPIO input event callback [00:00:07.158,325] <inf> NRFX_EXAMPLE: Timer finished. Context passed to the handler: >Some context< [00:00:07.158,355] <inf> NRFX_EXAMPLE: GPIOTE output pin: 28 is high [00:00:16.346,740] <inf> NRFX_EXAMPLE: GPIO input event callback [00:00:16.586,303] <inf> NRFX_EXAMPLE: GPIO input event callback [00:00:16.587,127] <inf> NRFX_EXAMPLE: GPIO input event callback [00:00:17.347,320] <inf> NRFX_EXAMPLE: Timer finished. Context passed to the handler: >Some context< [00:00:17.347,351] <inf> NRFX_EXAMPLE: GPIOTE output pin: 28 is high
Even if I comment this line "nrfx_gppi_channels_enable(BIT(gppi_channel_2));" the behavior doesn't change, but when I comment the 3rd PPI channel configuration as follows and flash the code, the output pin starts to respond.
status = nrfx_gppi_channel_alloc(&gppi_channel);
NRFX_ASSERT(status == NRFX_SUCCESS);
status = nrfx_gppi_channel_alloc(&gppi_channel_1);
NRFX_ASSERT(status == NRFX_SUCCESS);
status = nrfx_gppi_channel_alloc(&gppi_channel_2);
NRFX_ASSERT(status == NRFX_SUCCESS);
nrfx_gppi_channel_endpoints_setup(gppi_channel,
nrfx_timer_compare_event_address_get(&timer_inst, NRF_TIMER_CC_CHANNEL0),
nrfx_gpiote_out_task_addr_get(OUTPUT_PIN));
nrfx_gppi_channels_enable(BIT(gppi_channel));
nrfx_gppi_channel_endpoints_setup(gppi_channel_1,
nrfx_gpiote_in_event_addr_get(INPUT_PIN),
nrfx_timer_task_address_get(&timer_inst, NRF_TIMER_TASK_START));
nrfx_gppi_channels_enable(BIT(gppi_channel_1));
/*
nrfx_gppi_channel_endpoints_setup(gppi_channel_2,
nrfx_timer_compare_event_address_get(&timer_inst, NRF_TIMER_CC_CHANNEL0),
nrfx_timer_task_address_get(&timer_inst, NRF_TIMER_TASK_STOP));
*/
// nrfx_gppi_channels_enable(BIT(gppi_channel_2));
Also I noticed that the Input is triggered multiple times from the push button, is this related to the button bouncing?
[00:00:16.346,740] <inf> NRFX_EXAMPLE: GPIO input event callback
[00:00:16.586,303] <inf> NRFX_EXAMPLE: GPIO input event callback
[00:00:16.587,127] <inf> NRFX_EXAMPLE: GPIO input event callback
I'm using nrf5340DK, and NCS V2.4.0
My code is refactored from the "one_to_one" zephyr sample.
Best Regards,
Basem.