PIC16F-9-TIMER-PinDefinitions&PWMInitialization

by Marwen Maghrebi
// Define pin assignments for RGB LEDs
#define REDPin   RC0  // Red LED pin
#define GREENPin RC1  // Green LED pin
#define BLUEPin  RC2  // Blue LED pin

/**
 * Initialize Timer2 for PWM
 */
void PWM_Init() {
    PR2 = 255;  // Set period register for PWM period
    T2CKPS0 = 0;  // Set prescaler to 1:1
    T2CKPS1 = 0;
    TMR2ON = 1;  // Turn on Timer2
    CCP1M3 = 1;  // Configure CCP1 module for PWM mode
    CCP1M2 = 1;
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00