I've modified the button press example from nAN-36 using the ADC examples from the git repository.
What I'm trying to do is send the data sampled via the ADC using the real time clock via a notify as is used on the button in the application note. I've added the notify (using the on_button_change function in the ADC_IRQHandler.
I've also copied over the timing functions from the rtc example.
I've added breakpoints on the IRQHandler but it is never called. Am I wrong in assuming that the ppi will not trigger the interrupt via channel 0? It seems that outputting the result is also handled the same way in the example. Or will I need to make some modifications to the on_button_change function
static void ppi_init(void)
{
// Configure PPI channel 0 to start ADC task
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RTC0->EVENTS_TICK;
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_ADC->TASKS_START;
// Enable PPI channel 0
NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos);
}
void ADC_IRQHandler(void)
{
uint8_t adc_result;
uint32_t err_code;
/* Clear dataready event */
NRF_ADC->EVENTS_END = 0;
adc_result = NRF_ADC->RESULT;
//Use the STOP task to save current. Workaround for PAN_028 rev1.5 anomaly 1.
NRF_ADC->TASKS_STOP = 1;
//Release the external crystal
sd_clock_hfclk_release();
// Notify ADC property
err_code = ble_lbs_on_button_change(&m_lbs, adc_result);
if (err_code != NRF_SUCCESS &&
err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
}