Proteus: We will use RC1 PWM output, it may differ for each PIC model check the datasheet. You will observe that duty cycle will change 0-50% and dim the LED.
MCC: add CCP2 and TMR2 peripherals. Select RC1 as output in pin manager and pin module. at CCP2 peripheral, select PWM mode and 50% duty cycle. at TMR2, enable timer, 1:1 prescaler, 1:16 postscaler and 16.384ms period.
#include "mcc_generated_files/mcc.h"
#include "mcc_generated_files/pwm2.h"
/*
Main application
*/
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
while (1)
{
// Add your application code
for (int duty = 1; duty < 512; duty = duty + 10)
{
PWM2_LoadDutyValue(duty);
//for (int delay = 1; delay < 500; delay++)
//{;}
__delay_ms(100);
}
}
}
download the example
Learning Pic Programing With Xc8 Compiler: Pwm >>>>> Download Now
YanıtlaSil>>>>> Download Full
Learning Pic Programing With Xc8 Compiler: Pwm >>>>> Download LINK
>>>>> Download Now
Learning Pic Programing With Xc8 Compiler: Pwm >>>>> Download Full
>>>>> Download LINK rp