p. Digital to analog converter (DAC) based on PWM

All PIC microcontrollers are capable of generating PWM (pulse-width modulated) signal. See the schematic below to implement PWM to analog voltage level converter. The converter turns PWM signal with base frequency around 20 kHz to analog voltage level from 0 V to +5 V which is proportional to impulse width. Please, see PIC18F2xJ50 Programming guide or PIC32 programming guide on how to write a program for PIC18 or PIC32. The software provided on this website uses RC1 (from ECC1) and RC2 (from ECC2) outputs to generate PWM signal.