Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <htc.h>
- #include "serial.h"
- #include "delay.h"
- __CONFIG ( FOSC_HS & LVP_OFF & CP_OFF & WDTE_OFF ); // HS osc
- #define R 0x04 // RB2
- #define G 0x10 // RB4
- #define B 0x02 // RB1
- void main(void)
- {
- OSCCON = 0b01110000; // 8Mhz modus
- CM1CON0 = 0b00000000;
- CM2CON0 = 0b00000000;
- ADCON0 = 0b00000000;
- TRISB = 0b00000000;
- PORTB = 0x00;
- ANSELH = 0b00000000; //Clear analog bits to digital
- ANSEL = 0b00000000;
- PIE1 = 0b00000010; // Timer2 PR2 match on
- PIE2 = 0b00000000; // safety
- PIR1 = 0b00000000;
- PIR2 = 0b00000000;
- INTCON = 0b11000000; // GIE on, PEIE on
- T2CON = 0b01001101; // POST: 1:10, timer2 on, PRE: 1:4
- serial_setup();
- while(1)
- {
- PORTB ^= R + G + B;
- DelayS(1);
- }
- }
Add Comment
Please, Sign In to add comment