1 /******************************************************************************/
3 /******************************************************************************/
6 #include <xc.h> /* XC8 General Include File */
7 #elif defined(HI_TECH_C)
8 #include <htc.h> /* HiTech General Include File */
11 #include <stdint.h> /* For uint8_t definition */
12 #include <stdbool.h> /* For true/false definition */
17 /******************************************************************************/
19 /******************************************************************************/
21 /* <Initialize variables in user.h and insert code for user algorithms.> */
25 /* set watchdog to 4 seconds and enable it */
26 WDTCONbits.WDTPS = 0b01100;
27 WDTCONbits.SWDTEN = 1;
29 /* Select pins 4&5 as the uart - page 102 */
30 APFCONbits.RXDTSEL = 0; /* RX/DT on RA1 */
31 APFCONbits.TXCKSEL = 0; /* TX/CK on RA0 */
32 TRISAbits.TRISA1 = 1; /* RA5 as input */
33 TRISAbits.TRISA0 = 0; /* RA4 as output */
35 ANSELA = 0; /* no analog */
38 /* enable weak pullups, clear them all */
40 //WPUAbits.WPUA0 = 0x00000100; // RA0 pullup for 1-wire bus
41 OPTION_REGbits.nWPUEN = 1;
43 /* Enabling transmitter 26.1.1.1 page 259 - TX/CK I/O pin */
47 /* Enabling receiver 26.1.2 page 262 - RX/DT I/O pin */
50 /* 4MHz clock, 57k6 baud */
52 BAUDCONbits.BRG16 = 1;
57 // enable debug LED on RA4
63 // enable the timer (off for now, not gated mode)
65 T1GCONbits.TMR1GE = 0;
66 T1CONbits.TMR1CS = 0b00; // instruction clock
67 T1CONbits.T1CKPS = 0b11; // div 8
70 // enable TIMER1 interupt
73 /* Enable interrupts */
77 /* enable uart receiver interupt */