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

comp or lpcomp for 2 analog inputs with different v-- (ref)

i am working with nrf52832

i need to check 2 analog inputs and set my own v- (ref) 

i can have value read every few seconds so no fast readings needs to be done 

if i understand correctly i better use lpcomp if no fast readings is needed?

also,  is it possible, and if there are some code examples, to be reading 2 analog inputs with 2 different v-- (references) (one for each input pin) ?

best regards

Ziv

  • Are you trying to change the value of a variable you are passing into your function? In that case, you will need to pass it as a pointer(pass by reference) instead of its value(pass by value). The former will give you direct access to the variable's memory location, which you may then change. The latter only gives you a copy of the value at the time of reading, this copy will only exist within the scope of the function and is deleted at the return of the function.
    If the variable is declared within the function itself, you will need to use the 'static' keyword to indicate that the variable should not be reinitialized at every function call, and thus also not deleted at the end of each function call.
    The volatile keyword tells the compiler that the value of the variable might change at any time - independent of the program itself - such as the value of a register connected to a pushbutton, or other external trigger.

    i am familiar with all that .. i need to check if i get HIGH and LOW event one after the other for some reason

    basicaly the parameter is part of a globale instance of a struct

    That sounds strange. Are you saying that the output from your VDD channel held the value of one of the other channels?

    yes thats what i am saying, though i sisn't manage to repeat that fenomena again so i can not be sure what it means

    I would highly recommend using the PPI feature - it is a very powerful peripheral to use for your embedded application. If you would like to see some bare-metal code regarding timer usage and setup, you may do so here. Additionally, I will also warn you about mixing bare-metal programming and the nrfx drivers, since this may place the drivers in invalid states.

    like i wrote, right now i need the time it will take me to search for a way to use ppi with app_timer for other stufe like i2c and working with expander and nfc reader/writer (nxp) and also i could not find the beneffit of working with ppi if it calls for a handler that needs CPU anyway, if i understand corrctly the only thing that is different is that the ppi calls to the saadc handler without CPU and maybe the timer calls to the handler via its own handler so ther is one more call needing CPU    

    Best regards 

    Ziv

  • Hello again, Ziv

    All right - it sounds like you got it figured out, with your priorities in order.
    I am happy the issue is resolved and that you have the sought-after functionality up and running.

    Do not hesitate to open a new ticket if another issue should arise!

    Best regards,
    Karl

Related