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

COMP stop task

Right now I'm stuck with the COMP driver. What I am trying to do is. Initialise COMP, start COMP with interrupt and STOP shortcut. Once I handled the interrupt I just want to start the COMP again with an interrupt and a shortcut. However, when trying to start the COMP I am getting an exeption because in the nrf_drv_comp.c this fails:

ASSERT(m_state == NRF_DRV_STATE_INITIALIZED);

when I call

nrf_drv_comp_start(NRF_DRV_COMP_EVT_EN_DOWN_MASK, NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT);

My questions:

What is happening exactly when the stop task of the COMP is triggered due to interrupts?

In which state is the peripheral?

How can I use driver functions where m_state is checked when using interrupt shortcuts?

  • Hi, Did you figure this out yet?

    Te driver state should change from NRF_DRV_STATE_UNINITIALIZED to NRF_DRV_STATE_INITIALIZED when you call nrf_drv_comp_init() and vise versa when you call nrf_drv_comp_uninit().

    Furthermore the state will change to NRF_DRV_STATE_POWERED_ON when you start the comp with nrf_drv_comp_start(). Hence if you try to call nrf_drv_comp_start() once more by calling e.g. nrf_drv_comp_stop(), ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); will assert because the state is NRF_DRV_STATE_POWERED_ON

  • Thank you for your reply, meanwhile I'm familar with the COMP driver. My main question right now is, when I start the COMP after Init with:

    nrf_drv_comp_start(NRF_DRV_COMP_EVT_EN_DOWN_MASK, NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT);

    And the DOWN Event gets triggered the nRF is doing some magic and stopping the COMP. Is the driver module (m_state) aware that the COMP has been stopped? Meaning ist the STOP Task essentially the same as calling:

    nrf_drv_comp_stop()

  • It seems like I didn't read your initial post carefully enough, but I'm still not sure if I understand your question though. When you call nrf_drv_comp_start() with NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT as the second parameter you are telling the nRF to stop the the comparator after the first down event. This all happens inside the comparator HW with shortcuts and doesn't seem to change anything in the comp driver. Hence you will need to track this in your application yourself. If you just want the comparator to continue you can call nrf_drv_comp_start(NRF_DRV_COMP_EVT_EN_DOWN_MASK, 0);

  • OK, thank you. Yes, that was my question. I could wrap my head around how to use the Shortcut feature and nrf_drv APIs in combination. Now it makes sense.

Related