Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

ADC Example#

Overview#

This sample demonstrates the basic K230 ADC HAL workflow.

Source file:

src/rtsmart/examples/peripheral/adc/test_adc.c

Sample Behavior#

  • initialize ADC

  • read a raw value from the selected channel

  • convert it to a voltage value based on the selected reference voltage

Key APIs#

  • drv_adc_init()

  • drv_adc_read(channel)

  • drv_adc_read_uv(channel, ref_uv)

  • drv_adc_deinit()

Build and Run#

cd src/rtsmart/examples/peripheral/adc
make
./test_adc [channel] [ref_uv]
  • channel: ADC channel index, default 0

  • ref_uv: reference voltage in microvolts, only 1800000 or 3600000

Output Example#

The sample prints the raw ADC value and the converted voltage value for the selected channel.

Comments list
Comments
Log in