Hi,
I'm trying to simply toggle a pin with GPIOTE out toggle task from RTC2 CC0 event. Wrote up the following code and checked the registers in system viewer. Everything seems to check out but still not seeing the pin toggle. Any Ideas what I'm missing here? LFCLK is running @ 32.768kHz, app is modified from ble_app_hrs example.
static nrf_ppi_channel_t m_ppi_channel;
static const nrf_drv_rtc_t m_rtc = NRF_DRV_RTC_INSTANCE(2);
static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
{
}
static void rtc_config(void)
{
uint32_t err_code;
//Initialize RTC instance
err_code = nrf_drv_rtc_init(&m_rtc, NULL, rtc_handler);
APP_ERROR_CHECK(err_code);
/// Trigger CC0 at 500 ms
err_code = nrf_drv_rtc_cc_set(&m_rtc, 0 , 16383, false);
APP_ERROR_CHECK(err_code);
/// Configure gpiote channel to toggle output
nrf_drv_gpiote_out_config_t db_config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
err_code = nrf_drv_gpiote_out_init(DEBUG_TOGGLE, &db_config);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_out_task_enable(DEBUG_TOGGLE);
/// Wire RTC2 CC0 event to gpiote toggle task
err_code = nrf_drv_ppi_channel_alloc(&m_ppi_channel);
APP_ERROR_CHECK(err_code);
uint32_t rtc_cc_event_addr = nrf_drv_rtc_event_address_get(&m_rtc, NRF_RTC_EVENT_COMPARE_0);
uint32_t gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(DEBUG_TOGGLE);
err_code = nrf_drv_ppi_channel_assign(m_ppi_channel, rtc_cc_event_addr, gpiote_task_addr);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_enable(m_ppi_channel);
APP_ERROR_CHECK(err_code);
//Power on RTC instance
nrf_drv_rtc_enable(&m_rtc);
}