I've set up a timer which is firing the interrupt correctly. I then set up a second compare and linked it to the PPI to fire the ADC. The idea is to do these a few times per second, use the ADC interrupt to shift the ADC data pointer and then when the timer interrupt fires I've a history of reads. For now I only have the one compare linked for the ADC. All 8 pins are being read (in one go).
I'm using softdevice s112 but at the moment it's disabled.
#define CFG_PPI_TASKER_CHANNEL_ADC_START 1 #define CFG_PPI_TASKER_CHANNEL_ADC_START_POS PPI_CHENSET_CH1_Pos #define CFG_TASKER_PIF_TIMER NRF_TIMER2 #define ADC_CHANNEL_COUNT 8
// tasker timer CFG_TASKER_PIF_TIMER->CC[1] = 7813; // 1/4s CFG_TASKER_PIF_TIMER->CC[0] = 15625; // 1/2s CFG_TASKER_PIF_TIMER->PRESCALER = 9; CFG_TASKER_PIF_TIMER->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos; CFG_TASKER_PIF_TIMER->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos; NVIC_SetPriority(TIMER2_IRQn, 5); NVIC_EnableIRQ(TIMER2_IRQn); // adc for(uint8_t i=0; i < ADC_CHANNEL_COUNT; ++i) { NRF_SAADC->CH[i].PSELP = i+1; // .CONFIG = ; } NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL_10bit << SAADC_RESOLUTION_VAL_Pos; // 10 bit NRF_SAADC->RESULT.MAXCNT = ADC_CHANNEL_COUNT; NRF_SAADC->RESULT.PTR = (int32_t) &status.adc; NRF_SAADC->ENABLE = SAADC_ENABLE_ENABLE_Enabled << SAADC_ENABLE_ENABLE_Pos; NRF_SAADC->INTEN = SAADC_INTEN_END_Enabled << SAADC_INTEN_END_Pos; NVIC_SetPriority(SAADC_IRQn, 5); NVIC_EnableIRQ(SAADC_IRQn); // adc start scan NRF_PPI->CH[CFG_PPI_TASKER_CHANNEL_ADC_START].EEP = CFG_TASKER_PIF_TIMER->EVENTS_COMPARE[1]; // wire timer compare NRF_PPI->CH[CFG_PPI_TASKER_CHANNEL_ADC_START].TEP = NRF_SAADC->TASKS_START; NRF_PPI->CHENSET = 1 << CFG_PPI_TASKER_CHANNEL_ADC_START_POS; // enable ppi channel
Can anyone spot the problem? I've inspected the adc values and they're still 0 so it's not being triggered by the PPI.