* - (10) RA6 - unused
* - (11) RC0 - T1OSO
* - (12) RC1 - T1OSI
- * - (13) RC2 - CCP1 PWM for red LED
+ * - (13) RC2 - CCP1 PWM for wht LED
* - (14) RC3 - unused
* - (15) RC4 - unused
* - (16) RC5 - unused
* - (18) RC7 - unused
* - (19) Vss
* - (20) Vdd
- * - (21) RB0 - CCP4 PWM for wht LED
+ * - (21) RB0 - CCP4 PWM for blu LED
* - (22) RB1 - Pushbutton
* - (23) RB2 - Rocker switch, right
* - (24) RB3 - CCP2 PWM for grn LED
* - (25) RB4 - Rocker switch, left
- * - (26) RB5 - CCP3 PWM for blu LED
+ * - (26) RB5 - CCP3 PWM for red LED
* - (27) RB6 - ICSPCLK
* - (28) RB7 - ICSPDAT
*/
void rgb_init()
{
/* Initialize rgb
- * CCP1 on RC2, CCP2 on RB3, CCP3 on RB5, CCP4 on RB0
+ * red on CCP3/RB5, grn on CCP2/RB3, blu on CCP4/RB0, wht on CCP1/RC2
* - Fosc = 8 MHz, 4 MHz, 2 MHz
* - Prescale = 4, 1, 1
* - PRx value = 0xff
/* Configure CCP1 */
CCP1CON = 0b00001100;
- CCPR1L = 0; /* Initial red value; only using 8 LSBs */
+ CCPR1L = 0; /* Initial wht value; only using 8 LSBs */
/* Configure CCP2 */
CCP2SEL = 1; /* CCP2 is on RB3 */
CCPR2L = 0; /* Initial grn value; only using 8 LSBs */
/* Configure CCP3 */
- CCP3SEL = 1; /* CCP2 is on RB5 */
+ CCP3SEL = 1; /* CCP3 is on RB5 */
CCP3CON = 0b00001100;
- CCPR3L = 0; /* Initial blu value; only using 8 LSBs */
+ CCPR3L = 0; /* Initial red value; only using 8 LSBs */
/* Configure CCP4 */
CCP4CON = 0b00001100;
- CCPR4L = 0; /* Initial wht value; only using 8 LSBs */
+ CCPR4L = 0; /* Initial blu value; only using 8 LSBs */
/* Configure Timer2. Start it to set 0 outputs, then stop it. */
CCPTMRS0 = 0; /* CCP[1-4] use Timer 2 */
/* Set a PWM value for each color LED. 0=off, 255=full on. */
#define rgb_set(red, grn, blu, wht) do { \
ndi(); /* FIXME: doesn't seem to fix flicker */ \
- CCPR1L = (red); \
+ CCPR3L = (red); \
CCPR2L = (grn); \
- CCPR3L = (blu); \
- CCPR4L = (wht); \
+ CCPR4L = (blu); \
+ CCPR1L = (wht); \
nei(); \
} while (0)