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

DOUBT IN SAADC EXAMPLE FROM SDK V 14.2.0

HI,

       We are developing a 2d -3d  mouse with nRF5_SDK_14.2.0_17b948a  "ble_app_hids_mouse"  application.

  • For knowing the battery discharge rate of our product we are trying to implement adc into our code "modified ble_app_hids_mouse ".  
  • We are using p0.02(AIN0) for measuring  the battery status.
  • Actually our requirement is ,we want to check battery level(i.e adc value) at regular interval of time (may be 1m) and if the battery level is less than 20% we will turn on yellow led and if the battery level is less than 5% the red led will turn on.

For configuring the ADC , I look yours saadc code but i have some doubt in your code .

  • I think  in your saadc code they configured ADC ,TIMER AND PPI.

I will explain the flow of code execution what i understood from your saadc below if there is any mistake please correct me

  • TIMER will generate an event every 400ms .
  • By the help of PPI a task was occurring in SAADC peripheral   due to TIMER event . and its repeating at regular intervals (400 ms)
  1. "saadc_callback" function will execute when there is a TIMER event occur , is it right?
  2. During the initialization part(saadc_init) "nrf_drv_saadc_buffer_convert" function is calling and also inside the  "saadc_callback" function   is "nrf_drv_saadc_buffer_convert" function is calling . I known these function is for  issuing conversion of data to buffer. Then why its calling on both "saadc_init"  and  "saadc_callback" function.
  3. From which buffer we can read the converted analog to digital data ?

please answer to my 1,2 and 3

 if you need any clarification in my question please ask me .

Parents
  • Hi Hakon ,

       Thanks a lot .

    Now i got a better clarity  of Nordic "saadc" example.

    • Now i want implement this  saadc into our application code. i already told you that we are developing 2d -3d  comp mouse and we are using nRF5_SDK_14.2.0_17b948a  "ble_app_hids_mouse"  application.we modified this application with our own needs.
    • I decided to implement adc functionality into our application using TIMER and SAADC module only not using not using PPI.
    • Way of working is like below.

    1. First we will initialize the  TIMER and SAADC .
    2. TIMER is initialized in such a way that ,it will generate an event at every 1 min i.e the execution will enter into the "timer handler function"every 1 min repeatedly.
    3. Then inside this "timer handler function" i will call the  saadc functions for starting the saadc sampling i.e nrf_drv_saadc_sample and for read the adc result i.e  nrf_drv_saadc_buffer_convert  
    4. After reading the adc data then corresponding led will turn on if the adc result is less than a particular level.

    IS THERE ANY ISSUE WITH MY APPROACH ? IF THERE IS  ANY CHANGE NEED PLEASE TELL  ME.

Reply
  • Hi Hakon ,

       Thanks a lot .

    Now i got a better clarity  of Nordic "saadc" example.

    • Now i want implement this  saadc into our application code. i already told you that we are developing 2d -3d  comp mouse and we are using nRF5_SDK_14.2.0_17b948a  "ble_app_hids_mouse"  application.we modified this application with our own needs.
    • I decided to implement adc functionality into our application using TIMER and SAADC module only not using not using PPI.
    • Way of working is like below.

    1. First we will initialize the  TIMER and SAADC .
    2. TIMER is initialized in such a way that ,it will generate an event at every 1 min i.e the execution will enter into the "timer handler function"every 1 min repeatedly.
    3. Then inside this "timer handler function" i will call the  saadc functions for starting the saadc sampling i.e nrf_drv_saadc_sample and for read the adc result i.e  nrf_drv_saadc_buffer_convert  
    4. After reading the adc data then corresponding led will turn on if the adc result is less than a particular level.

    IS THERE ANY ISSUE WITH MY APPROACH ? IF THERE IS  ANY CHANGE NEED PLEASE TELL  ME.

Children
No Data
Related