Page 1 of 1

[MS51] Adjusting PWM Duty Cycle Based on ADC Input Voltage

Posted: 20 Feb 2023, 11:55
by chhsieh3
  • Application: This example code uses MS51 PWM to output 10 kHz waveform with 0~100% duty cycle according to 0~3V ADC input voltage.
  • BSP Version: MS51_Series_BSP_Keil_V1.00.004
  • Hardware: NuTiny-MS51DA V1.1
This example code uses MS51 PWM to output 10 kHz waveform with 0~100% duty cycle according to 0~3V ADC input voltage. The following sections show how to use ADC to sample an analog voltage and convert to 12-bit binary representation, and how to change PWM duty cycle through an ADC conversion result.

You can download the sample code at https://www.nuvoton.com/resource-downlo ... 1508110269