| Line No. | Rev | Author | Line | 
|---|---|---|---|
| 1 | 3 | kaklik | //////// Header file for the PIC16F88 | 
| 2 | #device PIC16F88 //PIC18F458 //PIC16F88 | ||
| 3 | #nolist | ||
| 4 | //////// Program memory: 4096x14  Data RAM: 368  Stack: 8 | ||
| 5 | //////// I/O: 16   Analog Pins: 7 | ||
| 6 | //////// Data EEPROM: 256 | ||
| 7 | //////// C Scratch area: 77   ID Location: 2000 | ||
| 8 | // Fuses: | ||
| 9 | // Oscilator: LP         - oscilator LP | ||
| 10 | //            XT         - oscilator XT | ||
| 11 | //            HS         - oscilator HS | ||
| 12 | //            EC_IO      - externi vstup, RA6/CLKO je IO port | ||
| 13 | //            INTRC      - RC oscilator,  RA6/CLKO je CLKO, RA7/CLKI je IO port port, | ||
| 14 | //            INTRC_IO   - RC oscilator,  RA6 i RA7 je IO port | ||
| 15 | //            RC         - ext RC, RA6/CLKO je CLKO | ||
| 16 | //            RC_IO      - ext RC, RA6 je IO port | ||
| 17 | // Watch:     NOWDT      - neni watchog | ||
| 18 | //            WDT        - je watchdog | ||
| 19 | // PUT:       NOPUT      - neni power up timer | ||
| 20 | //            PUT        - je power up timer | ||
| 21 | // MCLR:      MCLR       - RA5/MCLR je MCLR | ||
| 22 | //            NOMCLR     - RA5/MCLR je IO port | ||
| 23 | // BOR:       BROWNOUT   - BOR povolen | ||
| 24 | //            NOBROWNOUT - BOR zakazan | ||
| 25 | // LVP:       LVP        - RB3/PGM je PGM | ||
| 26 | //            NOLVP      - RB3/PGM je IO port | ||
| 27 | // CPD:       CPD        - je ochrana EEPROM | ||
| 28 | //            NOCPD      - neni ochrana EEPROM | ||
| 29 | // WRT        WRT        - zakaz zapisu do pameti programu | ||
| 30 | //            NOWRT      - povolen zapis do pameti programu | ||
| 31 | // DEBUG:     DEBUG      - RB6 a RB7 jsou ICD port | ||
| 32 | //            NODEBUG    - RB6 a RB7 jsou IO port | ||
| 33 | // CCPMX:     CCPB0      - CCP/PWM na RB0 | ||
| 34 | //            CCPB3      - CCP/PWM na RB3 | ||
| 35 | // CP:        PROTECT    - pamet programu je chranena | ||
| 36 | //            NOPROTECT  - pamet programu neni chranena | ||
| 37 | // | ||
| 38 | |||
| 39 | ////////////////////////////////////////////////////////////////// I/O | ||
| 40 | // Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(), | ||
| 41 | //                         PORT_B_PULLUPS(), INPUT(), | ||
| 42 | //                         OUTPUT_LOW(), OUTPUT_HIGH(), | ||
| 43 | //                         OUTPUT_FLOAT(), OUTPUT_BIT() | ||
| 44 | // Constants used to identify pins in the above are: | ||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | #define PIN_A0  40 | ||
| 49 | #define PIN_A1  41 | ||
| 50 | #define PIN_A2  42 | ||
| 51 | #define PIN_A3  43 | ||
| 52 | #define PIN_A4  44 | ||
| 53 | #define PIN_A5  45 | ||
| 54 | #define PIN_A6  46 | ||
| 55 | #define PIN_A7  47 | ||
| 56 | |||
| 57 | #define PIN_B0  48 | ||
| 58 | #define PIN_B1  49 | ||
| 59 | #define PIN_B2  50 | ||
| 60 | #define PIN_B3  51 | ||
| 61 | #define PIN_B4  52 | ||
| 62 | #define PIN_B5  53 | ||
| 63 | #define PIN_B6  54 | ||
| 64 | #define PIN_B7  55 | ||
| 65 | |||
| 66 | ////////////////////////////////////////////////////////////////// Useful defines | ||
| 67 | #define FALSE 0 | ||
| 68 | #define TRUE 1 | ||
| 69 | |||
| 70 | #define BYTE int | ||
| 71 | #define BOOLEAN short int | ||
| 72 | |||
| 73 | #define getc getch | ||
| 74 | #define fgetc getch | ||
| 75 | #define getchar getch | ||
| 76 | #define putc putchar | ||
| 77 | #define fputc putchar | ||
| 78 | #define fgets gets | ||
| 79 | #define fputs puts | ||
| 80 | |||
| 81 | ////////////////////////////////////////////////////////////////// Control | ||
| 82 | // Control Functions:  RESET_CPU(), SLEEP(), RESTART_CAUSE() | ||
| 83 | // Constants returned from RESTART_CAUSE() are: | ||
| 84 | #define WDT_FROM_SLEEP  0 | ||
| 85 | #define WDT_TIMEOUT     8 | ||
| 86 | #define MCLR_FROM_SLEEP 16 | ||
| 87 | #define NORMAL_POWER_UP 24 | ||
| 88 | |||
| 89 | |||
| 90 | ////////////////////////////////////////////////////////////////// Timer 0 | ||
| 91 | // Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER0(), | ||
| 92 | //                              SET_TIMER0() or SET_RTCC(), | ||
| 93 | //                              GET_TIMER0() or GET_RTCC() | ||
| 94 | // Constants used for SETUP_TIMER0() are: | ||
| 95 | #define RTCC_INTERNAL   0 | ||
| 96 | #define RTCC_EXT_L_TO_H 32 | ||
| 97 | #define RTCC_EXT_H_TO_L 48 | ||
| 98 | |||
| 99 | #define RTCC_DIV_1      8 | ||
| 100 | #define RTCC_DIV_2      0 | ||
| 101 | #define RTCC_DIV_4      1 | ||
| 102 | #define RTCC_DIV_8      2 | ||
| 103 | #define RTCC_DIV_16     3 | ||
| 104 | #define RTCC_DIV_32     4 | ||
| 105 | #define RTCC_DIV_64     5 | ||
| 106 | #define RTCC_DIV_128    6 | ||
| 107 | #define RTCC_DIV_256    7 | ||
| 108 | |||
| 109 | |||
| 110 | #define RTCC_8_BIT      0 | ||
| 111 | |||
| 112 | // Constants used for SETUP_COUNTERS() are the above | ||
| 113 | // constants for the 1st param and the following for | ||
| 114 | // the 2nd param: | ||
| 115 | |||
| 116 | ////////////////////////////////////////////////////////////////// WDT | ||
| 117 | // Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above) | ||
| 118 | //                            RESTART_WDT() | ||
| 119 | // | ||
| 120 | #define WDT_18MS        8 | ||
| 121 | #define WDT_36MS        9 | ||
| 122 | #define WDT_72MS       10 | ||
| 123 | #define WDT_144MS      11 | ||
| 124 | #define WDT_288MS      12 | ||
| 125 | #define WDT_576MS      13 | ||
| 126 | #define WDT_1152MS     14 | ||
| 127 | #define WDT_2304MS     15 | ||
| 128 | |||
| 129 | ////////////////////////////////////////////////////////////////// Timer 1 | ||
| 130 | // Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1 | ||
| 131 | // Constants used for SETUP_TIMER_1() are: | ||
| 132 | //      (or (via |) together constants from each group) | ||
| 133 | #define T1_DISABLED         0 | ||
| 134 | #define T1_INTERNAL         0x85 | ||
| 135 | #define T1_EXTERNAL         0x87 | ||
| 136 | #define T1_EXTERNAL_SYNC    0x83 | ||
| 137 | |||
| 138 | #define T1_CLK_OUT          8 | ||
| 139 | |||
| 140 | #define T1_DIV_BY_1         0 | ||
| 141 | #define T1_DIV_BY_2         0x10 | ||
| 142 | #define T1_DIV_BY_4         0x20 | ||
| 143 | #define T1_DIV_BY_8         0x30 | ||
| 144 | |||
| 145 | ////////////////////////////////////////////////////////////////// Timer 2 | ||
| 146 | // Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2 | ||
| 147 | // Constants used for SETUP_TIMER_2() are: | ||
| 148 | #define T2_DISABLED         0 | ||
| 149 | #define T2_DIV_BY_1         4 | ||
| 150 | #define T2_DIV_BY_4         5 | ||
| 151 | #define T2_DIV_BY_16        6 | ||
| 152 | |||
| 153 | ////////////////////////////////////////////////////////////////// CCP | ||
| 154 | // CCP Functions: SETUP_CCPx, SET_PWMx_DUTY | ||
| 155 | // CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH | ||
| 156 | // Constants used for SETUP_CCPx() are: | ||
| 157 | #define CCP_OFF                         0 | ||
| 158 | #define CCP_CAPTURE_FE                  4 | ||
| 159 | #define CCP_CAPTURE_RE                  5 | ||
| 160 | #define CCP_CAPTURE_DIV_4               6 | ||
| 161 | #define CCP_CAPTURE_DIV_16              7 | ||
| 162 | #define CCP_COMPARE_SET_ON_MATCH        8 | ||
| 163 | #define CCP_COMPARE_CLR_ON_MATCH        9 | ||
| 164 | #define CCP_COMPARE_INT                 0xA | ||
| 165 | #define CCP_COMPARE_RESET_TIMER         0xB | ||
| 166 | #define CCP_PWM                         0xC | ||
| 167 | #define CCP_PWM_PLUS_1                  0x1c | ||
| 168 | #define CCP_PWM_PLUS_2                  0x2c | ||
| 169 | #define CCP_PWM_PLUS_3                  0x3c | ||
| 170 | long CCP_1; | ||
| 171 | #byte   CCP_1    =                      0x15 | ||
| 172 | #byte   CCP_1_LOW=                      0x15 | ||
| 173 | #byte   CCP_1_HIGH=                     0x16 | ||
| 174 | ////////////////////////////////////////////////////////////////// COMP | ||
| 175 | // Comparator Variables: C1OUT, C2OUT | ||
| 176 | // Constants used in setup_comparators() are: | ||
| 177 | #define A0_A3_A1_A2  4 | ||
| 178 | #define A0_A2_A1_A2  3 | ||
| 179 | #define NC_NC_A1_A2  5 | ||
| 180 | #define NC_NC_NC_NC  7 | ||
| 181 | #define A0_VR_A1_VR  2 | ||
| 182 | #define A3_VR_A2_VR  10 | ||
| 183 | #define A0_A2_A1_A2_OUT_ON_A3_A4 6 | ||
| 184 | #define A3_A2_A1_A2  9 | ||
| 185 | |||
| 186 | //#bit C1OUT = 0x1f.6 | ||
| 187 | //#bit C2OUT = 0x1f.7 | ||
| 188 | |||
| 189 | ////////////////////////////////////////////////////////////////// VREF | ||
| 190 | // Constants used in setup_vref() are: | ||
| 191 | #define VREF_LOW  0xa0 | ||
| 192 | #define VREF_HIGH 0x80 | ||
| 193 | #define VREF_A2   0x40 | ||
| 194 | |||
| 195 | ////////////////////////////////////////////////////////////////// INT | ||
| 196 | // Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(), | ||
| 197 | //                      EXT_INT_EDGE() | ||
| 198 | // | ||
| 199 | // Constants used in EXT_INT_EDGE() are: | ||
| 200 | #define L_TO_H              0x40 | ||
| 201 | #define H_TO_L                 0 | ||
| 202 | // Constants used in ENABLE/DISABLE_INTERRUPTS() are: | ||
| 203 | #define GLOBAL                    0x0BC0 | ||
| 204 | #define INT_RTCC                  0x0B20 | ||
| 205 | #define INT_RB                    0x0B08 | ||
| 206 | #define INT_EXT                   0x0B10 | ||
| 207 | #define INT_TBE                   0x8C10 | ||
| 208 | #define INT_RDA                   0x8C20 | ||
| 209 | #define INT_TIMER1                0x8C01 | ||
| 210 | #define INT_TIMER2                0x8C02 | ||
| 211 | #define INT_CCP1                  0x8C04 | ||
| 212 | #define INT_SSP                   0x8C08 | ||
| 213 | #define INT_COMP                  0x8D40 | ||
| 214 | #define INT_EEPROM                0x8D10 | ||
| 215 | #define INT_TIMER0                0x0B20 | ||
| 216 | #list | 
Powered by WebSVN v2.8.3