The ADC Example demonstrates the use of the analog-to-digital converter (ADC) peripheral in a simple way. It uses the ADC driver .
The example initializes ADC and constantly samples the analog input 2 on pin 1. The output is printed on UART. The example is event-driven, which means that no busy loops are used. Therefore, the CPU can be turned off during inactive periods.
The provided event handler is called by the driver when a new sampling result is available. The result is enclosed in a proper text message and transmitted via UART. The main loop of the example is empty. It is used only to put the CPU into low-power consumption mode.
You can find the source code and the project file of the example in the following folder:
<InstallFolder>\examples\peripheral\adc
Testing
Test the ADC HAL Example application by performing the following steps:
- Compile and program the application.
-
Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
- Baud rate: 115.200
- 8 data bits
- 1 stop bit
- No parity
- HW flow control: None
-
Check the output and observe that:
- After reset, basic information about the example is output on UART.
- When the example is running, the ADC samples analog input 2 and outputs the result value on UART.