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

lpComp reference change

I wonder if it is OK to change the lpcomp ref input on the fly, without any other stop task or disable/enable. Just like this:

//--------------------

static void lpcomp_set_ref(int hl)
{
if (hl == 1)

NRF_LPCOMP->REFSEL = (NRF_LPCOMP_REF_SUPPLY_7_8 << LPCOMP_REFSEL_REFSEL_Pos) & LPCOMP_REFSEL_REFSEL_Msk;
else
NRF_LPCOMP->REFSEL = (NRF_LPCOMP_REF_SUPPLY_1_8 << LPCOMP_REFSEL_REFSEL_Pos) & LPCOMP_REFSEL_REFSEL_Msk;
}

//---------------------------------

Thanks

Parents
  • Hi Jonhanan, 

    I apologize for the late reply. 

    No, the LPCOMP  must be stopped before modifying PSEL or any other configuration register and then started again for the change to take affect. 

    Best regards

    Bjørn 

  • Well, I checked this code and it works.

    I need to have a relaxation oscillator, which is a resistor from one pin charging/discharging a capacitor on LPCOMP input. Every time a DOWN/UP event on LPCOMP, it will change  the charging polarity and change the LPCOMP ref voltage via interrupt (which will happen long before the voltage passes the HYST gap).

    This way I can make sure that capacitor voltage will be from 1/8 VCC to 7/8 VCC. I did not implement ppi yet, but I would like to do it.(current version works software only, no ppi)

    I can see that this voltage ref change works without STOP of LPCOMP, do I really need it? what will be the  effect on the working speed? What is the risk of doing it without STOP (As I said, it does work)?

    Thanks for you comments.

    Johanan

  • A similar question was asked here on DevZone which triggered a discussion with the LPCOMP architects and they indicated that that changing the REFSEL with the LPCOMP could affect the time it takes for the reference to stabilize. The startup time of the LPCOMP can be up-to 135uS. 

Reply Children
No Data
Related