nrf52840, sdk17. pca10056 (for now). linux arm-gcc, gnumake, etc.
I have a fairly complex PPI configuration but in the act of debugging it, I've dumbed it down quite a bit. So for now, I've got TIMER2 configured in timer mode @16Mhz. I'm trying to toggle a couple of GPIOTEs at 182usec, for example. Should be fairly straight forward.
Salient parts of my code:
#define CS_0 NRF_GPIO_PIN_MAP(0, 7)
#define ADS_CS CS_0
#define COUNTER_CLOCK NRF_GPIO_PIN_MAP(0,29)
static const nrfx_timer_t timer2_instance = NRFX_TIMER_INSTANCE(2);
nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;
timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;
static const nrfx_gpiote_out_config_t toggle_task = NRFX_GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
ret_code_t err_code = nrfx_timer_init(&timer2, &timer_cfg, empty_timer_handler);
nrfx_timer_extended_compare(&timer2, NRF_TIMER_CC_CHANNEL0, nrfx_timer_us_to_ticks(&timer2, interval+20),
NRF_TIMER_SHORT_COMPARE2_CLEAR_MASK, true);
nrfx_gpiote_out_init(COUNTER_CLOCK, &toggle_task);
nrfx_gpiote_out_init(ADS_CS, &toggle_task);
nrf_ppi_channel_t channel[CHAIN0_CHANNEL_COUNT];
nrf_ppi_channel_group_t channel_group;
err_code = nrfx_ppi_channel_alloc(&channel[0]);
err_code = nrfx_ppi_channel_assign(channel[0],
nrfx_timer_event_address_get(&timer2_instance, NRF_TIMER_EVENT_COMPARE0),
nrfx_gpiote_out_task_addr_get(COUNTER_CLOCK));
err_code = nrfx_ppi_group_alloc(&channel_group);
nrfx_ppi_channel_include_in_group(channel[0], channel_group);
err_code = nrfx_ppi_group_enable(channel_group);
I have a logic analyzer hooked up to the relevant pins and I can verify that they move when I change the toggle_task from low/high for nrfx_gpiote_out_init().
In my mainloop, I have:
while(true)
{
nrf_delay_us(1000000);
NRF_LOG_INFO("timer2: %d zzz", nrfx_timer_capture_get(&timer2,NRF_TIMER_CC_CHANNEL0));
NRF_LOG_FLUSH();
}
...and I confirm that my timer has reached the COMPARE0 trigger. But my GPIOs don't actually toggle.
<info> app: timer2: 2912 zzz
It's probably something really dumb but I'm not sure how else to debug this.
(first time using PPI. Prior experience with Nordic devices was nrf51822 a number of years ago).