Convert ADC Code to Voltage

Easy C DSP
Solve this problem

Convert a 12-bit ADC raw code to voltage using reference voltage. Result returned as floating point.

Constraints

  • ADC resolution = 4096.
  • Formula: V = code * Vref / 4095.
  • Use float.
  • Return voltage.
Starter codeC
1float adc_to_v(uint16_t code, float vref);