This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

capsense without PPI nRF52

I would like to use the capsense example with a Bluetooth application. But as it's not compatible with softdevice, I want to modify it. Two questions:

1 – As anyone already done it?

If not, I would like to use handler function instead of PPI, but I don’t know how to call a function from an event without nrf_drivers. Because the capsense example use Hardware Access Layer.

2 – How do I set a callback function from a comparator event in HAL? Or do I need to rewrite all the example and use the drivers functions?

I tried to replace this :

static void config_ppi(void)
{
	// Use PPI to start timer at upward crossing
	NRF_PPI->CH[CAPSENSE_PPI_CH0].EEP = (uint32_t)&NRF_COMP->EVENTS_UP;
	NRF_PPI->CH[CAPSENSE_PPI_CH0].TEP = (uint32_t)&CAPSENSE_TIMER->TASKS_START;
	NRF_PPI->CHENSET = 1 << CAPSENSE_PPI_CH0;
	// Use PPI to capture timer at downward crossing to CC[0] and stop
	// the timer
	NRF_PPI->CH[CAPSENSE_PPI_CH1].EEP = (uint32_t)&NRF_COMP->EVENTS_DOWN;
	NRF_PPI->CH[CAPSENSE_PPI_CH1].TEP = (uint32_t)&CAPSENSE_TIMER->TASKS_CAPTURE[0];
	NRF_PPI->FORK[CAPSENSE_PPI_CH1].TEP = (uint32_t)&CAPSENSE_TIMER->TASKS_STOP;
	NRF_PPI->CHENSET = 1 << CAPSENSE_PPI_CH1;
}

with this :

void COMP_LPCOMP_IRQHandler(void)
{
	// This interrupt is triggered when a sample has been
	// collected. The "sample" is the half period of the oscillator
	// (which is depandent of the capacitance of the sensor).

	if(NRF_COMP->EVENTS_UP)
	{
		NRF_COMP->EVENTS_UP = 0;
		CAPSENSE_TIMER->TASKS_START = 1;
	}
	if (NRF_COMP->EVENTS_DOWN)
	{
		CAPSENSE_TIMER->TASKS_CAPTURE[0] = 1;
		CAPSENSE_TIMER->TASKS_STOP = 1;
		NRF_COMP->EVENTS_DOWN = 0;
		if (m_calibration_active)
		{
			calibration_sample_finalize();
		}
		else
		{
			sample_finalize();
		}
		CAPSENSE_TIMER->TASKS_START = 0;
		CAPSENSE_TIMER->TASKS_CAPTURE[0] = 0;
		CAPSENSE_TIMER->TASKS_STOP = 0;
	}
}

But it doesn't work.

Parents Reply Children
No Data
Related