Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SAADC changing value range (signed to unsigned)

Hello Nordic Support,

I am using SAADC on nRF52840 with nRF5_SDK_15.3.0_59ac345

I use the following configurations:

{ 
    .resolution         = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION, // 12 bits
    .oversample         = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE, // 0
    .interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY,                       // 5
    .low_power_mode     = NRFX_SAADC_CONFIG_LP_MODE                             // 0
}


{                                                   
    .resistor_p = NRF_SAADC_RESISTOR_DISABLED,      
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,      
    .gain       = NRF_SAADC_GAIN1_6,                
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,     
    .acq_time   = NRF_SAADC_ACQTIME_10US,           
    .mode       = NRF_SAADC_MODE_SINGLE_ENDED,      
    .burst      = NRF_SAADC_BURST_DISABLED,         
    .pin_p      = (nrf_saadc_input_t)(NRF_SAADC_INPUT_AIN1),       
    .pin_n      = NRF_SAADC_INPUT_DISABLED          
}

The SAADC value, as I have been using is signed. I wonder if Nordic will later support unsigned value, or you will not? Or are there any ways to convert from signed SAADC to unsigned SAADC?

Thank you and best regards,

           Duy

Parents
  • Hello ,

    Thank you for your reply. It is because I am communicating with a device whose output is 0V to 1.9V and I want to use all 12 bits of the SAADC. In my case, I can only use 11 bits if the output of my device is 0V -> 1.9V. Is it right? 

    Best regards,

         Duy

  • Duy said:
    In my case, I can only use 11 bits if the output of my device is 0V -> 1.9V. Is it right? 

     I'm not sure I understand you correctly, the result is stored as an 16 bit int. The number of bits you use is dependent on the chosen resolution. All bits will be set to 1's when you've reached the reference/gain. The reference/gain value should be set to the maximum voltage that you would want to measure. 

  • Sorry for making the question note clear enough. Here is my calculation.

    For example I got:

        + VDD = 2.4V

        + Reference = VDD/4; Gain = 1/4

        + Input range = (VDD/4)/(1/4) = 2.4V

        + Single-ended ADC

        + ADC resolution = 12 bit (-2048 to 2047?)

    So if my ADC is around 0 to 2.4V, the ADC I got will be from 0 to 2047, is it right?

    And when the input is 2.4V, the ADC value (I get after calling the convert buffer function) will be = 1111 1000 0000 0000b.

    Is this right?

    And sometimes I get the result (after calling the convert buffer function): -7, -8, -4...to -1. What is the reason for this result? As I read from this post, this is the offset. But what is the truly input voltage when I got that small negative result?

    Thank you and best regards,

                Duy

Reply
  • Sorry for making the question note clear enough. Here is my calculation.

    For example I got:

        + VDD = 2.4V

        + Reference = VDD/4; Gain = 1/4

        + Input range = (VDD/4)/(1/4) = 2.4V

        + Single-ended ADC

        + ADC resolution = 12 bit (-2048 to 2047?)

    So if my ADC is around 0 to 2.4V, the ADC I got will be from 0 to 2047, is it right?

    And when the input is 2.4V, the ADC value (I get after calling the convert buffer function) will be = 1111 1000 0000 0000b.

    Is this right?

    And sometimes I get the result (after calling the convert buffer function): -7, -8, -4...to -1. What is the reason for this result? As I read from this post, this is the offset. But what is the truly input voltage when I got that small negative result?

    Thank you and best regards,

                Duy

Children
Related