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
  • Hello, can you explain what are you trying to achieve? What is your setup MCU, sdk, softdevice? what does the error says? Recently I had problems while using SAADC. I would recommend you to take a look at proximity example. Moreover, do you do temperature calibration?

  • i use the softdevice, sdk is nRF5_SDK_12.3.0_d7731ad.

    my error is that i said in above. 

    when i use saadc,anything is ok. But i wanna uninit the saadc to power down the consumption.

    But when i init saadc in twice more,saadc cant work well. 

     nrf_drv_saadc_sample error is 0x08, That means saadc is not busy.

    i bubeg the code , and i find the code enter if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED)) in SAADC_IRQHandler.

    why when i init saadc in twice more,the code enter nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED)???

  • try uninit saadc like this: 

    nrf_drv_saadc_uninit();
    NRF_SAADC->INTENCLR = (SAADC_INTENCLR_END_Clear << SAADC_INTENCLR_END_Pos);
    NVIC_ClearPendingIRQ(SAADC_IRQn);

    Do you see that power consumption actualy goes down when you unitiliaze? I guess it might be that you do not unitiliaze it properly. This would explain why code works good until initialized for the second time.

    Does blocking function does not fit your plan?

Reply
  • try uninit saadc like this: 

    nrf_drv_saadc_uninit();
    NRF_SAADC->INTENCLR = (SAADC_INTENCLR_END_Clear << SAADC_INTENCLR_END_Pos);
    NVIC_ClearPendingIRQ(SAADC_IRQn);

    Do you see that power consumption actualy goes down when you unitiliaze? I guess it might be that you do not unitiliaze it properly. This would explain why code works good until initialized for the second time.

    Does blocking function does not fit your plan?

Children
No Data
Related