4 Triangle Waveform Generation with Variable Amplitude Using ADC, DAC and APM
The following use case was designed to highlight the capabilities of the APM as well as to showcase its configuration in MCC Melody. The FVR peripheral is used to provide fixed voltage references of 2.048 V and 4.096 V to the ADC and DAC peripherals respectively. The DAC peripheral is used to output a triangle waveform with variable amplitude controlled by the value measured with the ADC from a potentiometer. The APM is configured as the auto-conversion trigger source for the ADC, and the TMR1 module’s overflow interrupt is used to alter the output of the DAC. The ADC peripheral’s conversion-complete interrupt is used to modify the amplitude of the triangle waveform. The APM periodically enables the FVR to set the voltage references, the ADC to perform a single conversion and the DAC to output the triangle waveform.