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

The Saadc of issue of uninit

i init the saadc and uinit saadc ,then init saadc again. my code is below:

err_code = nrf_drv_saadc_init(NULL, saadc_callback);
err_code = nrf_drv_saadc_channel_init(0, &channel_config_se1);
err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool, 1);

 nrf_drv_saadc_uninit();

err_code = nrf_drv_saadc_init(NULL, saadc_callback);
err_code = nrf_drv_saadc_channel_init(0, &channel_config_se1);
err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool, 1);

from now .the err_code is correct .

But when i use nrf_drv_saadc_sample(), geting a error in SAADC_IRQHandler. And this is my callback:

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
{
nrf_drv_saadc_buffer_convert(m_buffer_pool,1);
}

In SAADC_IRQHandler, the code enter in below:

if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED))
{
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
NRF_LOG_DEBUG("Event: %s.\r\n", (uint32_t)EVT_TO_STR(NRF_SAADC_EVENT_STOPPED));
m_cb.adc_state = NRF_SAADC_STATE_IDLE;
}

if i dont use  nrf_drv_saadc_uninit(),there is greater.

what i can do???

Parents Reply
  • The uninit function will stay in a while loop until the STOPPED event is generated. There is no need for interrupts to be enabled in order for events to be generated. If you frequently pull the STOPPED event register, you will read the event when it is generated. If a timeout should happen for some reason, before the STOPPED event is generated, this should be caught by the ASSERT (given that you have enabled ASSERTS by defining symbol DEBUG_NRF in the preprocessor symbols). You will not be able to call init function before the STOPPED event is generated, or you will be trapped in assert handler.

Children
Related