This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I don't understand the role of "data.done.p_buffer[]".

Hello
I am implementing a battery voltage monitoring function using nrf52840. I am a beginner in hardware development. As the first step of this function, I am currently implementing a function to read the voltage value. I am using the function "es_battery_voltage_get()" to read out the data. I have a question about "data.done.p_buffer[]" in saadc_event_handler(), which is a kson of the saadc source file. In this array, the default index was 0, but when I changed it to 1, the output voltage value increased about 20 times. I had no idea what voltage was being represented. So, I was wondering if you could tell me the meaning of the variable "data.done.p_buffer[]", including that point. Thank you very much. Thank you in advance.

static void saadc_event_handler(nrf_drv_saadc_evt_t const * p_evt)
{
    if (p_evt->type == NRF_DRV_SAADC_EVT_DONE)
    {
        nrf_saadc_value_t adc_result;

        adc_result = p_evt->data.done.p_buffer[1];

        m_batt_lvl_in_milli_volts =
            ADC_RESULT_IN_MILLI_VOLTS(adc_result) + DIODE_FWD_VOLT_DROP_MILLIVOLTS;
        
        
    }
}

LemonCake

Related