I'm getting the NRF_ERROR_NO_MEM when I try to put my ADC interrupt routine into the scheduler. The code runs without error if I run from the ADC interrupt handler directly but hits the NVIC_system_reset if I try to put the code into the scheduler. I'm using the scheduler else where in my code without issue. This is with NRF51822 and SD 8. This works fine:
void ADC_IRQHandler(void){
nrf_adc_conversion_event_clean();
if (measure_bat == true)
{
batt_voltage = nrf_adc_result_get();
}
else if (measure_hwid == true)
{
hwid = nrf_adc_result_get();
}
debug_uart_test();
measure_bat = false;
measure_hwid = false;
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
NVIC_DisableIRQ(ADC_IRQn);
}
But if I try to do this, it resets with NRF_ERROR_NO_MEM
void ADC_IRQHandler(void) {
ret_code_t err_code; err_code = app_sched_event_put(NULL, 0, adc_scheduler_handler); APP_ERROR_CHECK(err_code);
}
void adc_scheduler_handler(void *data, uint16_t size) {
nrf_adc_conversion_event_clean();
if (measure_bat == true)
{
batt_voltage = nrf_adc_result_get();
}
else if (measure_hwid == true)
{
hwid = nrf_adc_result_get();
}
debug_uart_test();
measure_bat = false;
measure_hwid = false;
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_DISABLED);
NVIC_DisableIRQ(ADC_IRQn);
}
PS Any tips on how to format my code on this forum? The auto format doesn't seem to recognize chunks of my code...