This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

timer as counter - no interrupt while using event

I tried to use Timer2 as counter with event and interrupt. event is working. interrupt not.

<pre><code>

timer_count_cfg.mode = NRF_TIMER_MODE_COUNTER;
err_code = nrf_drv_timer_init(&twi_xfercounter_timer, &timer_count_cfg, timer_xfercounter_event_handler);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_alloc(&ppi_twi_xfer_count);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_assign(ppi_twi_xfer_count,
										    (uint32_t)nrf_twim_event_address_get(NRF_TWIM0, NRF_TWIM_EVENT_STOPPED),
											(uint32_t)nrf_timer_task_address_get(twi_xfercounter_timer.p_reg, NRF_TIMER_TASK_COUNT)
										  );
APP_ERROR_CHECK(err_code);

nrf_drv_timer_extended_compare(&twi_xfercounter_timer, NRF_TIMER_CC_CHANNEL0, (uint32_t)Steps, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrf_drv_timer_enable(&twi_xfercounter_timer);

// ---------------------------------

void timer_xfercounter_event_handler(nrf_timer_event_t event_type, void *p_context)
{
	ret_code_t err_code;
	
	NRF_LOG_INFO("Interrupt\r\n");

	if(event_type == NRF_TIMER_EVENT_COMPARE0)
	{
		// Übertragung abgeschlossen.
		// Deaktiviere die PPIs:
		err_code = nrf_drv_ppi_channel_disable(ppi_twi_xfer_count);
		APP_ERROR_CHECK(err_code);

		TWI_Transfer_In_Progress = false;
	}
}
</pre></code>
Parents Reply Children
No Data
Related