Rev 193 Rev 195
1 //////// Header file for the PIC16F88 1 //////// Header file for the PIC16F88
2 #device PIC16F88 2 #device PIC16F88
3 #nolist 3 #nolist
4 //////// Program memory: 4096x14 Data RAM: 368 Stack: 8 4 //////// Program memory: 4096x14 Data RAM: 368 Stack: 8
5 //////// I/O: 16 Analog Pins: 7 5 //////// I/O: 16 Analog Pins: 7
6 //////// Data EEPROM: 256 6 //////// Data EEPROM: 256
7 //////// C Scratch area: 77 ID Location: 2000 7 //////// C Scratch area: 77 ID Location: 2000
8 // Fuses: 8 // Fuses:
9 // Oscilator: LP - oscilator LP 9 // Oscilator: LP - oscilator LP
10 // XT - oscilator XT 10 // XT - oscilator XT
11 // HS - oscilator HS 11 // HS - oscilator HS
12 // EC_IO - externi vstup, RA6/CLKO je IO port 12 // EC_IO - externi vstup, RA6/CLKO je IO port
13 // INTRC - RC oscilator, RA6/CLKO je CLKO, RA7/CLKI je IO port 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 14 // INTRC_IO - RC oscilator, RA6 i RA7 je IO port
15 // RC - ext RC, RA6/CLKO je CLKO 15 // RC - ext RC, RA6/CLKO je CLKO
16 // RC_IO - ext RC, RA6 je IO port 16 // RC_IO - ext RC, RA6 je IO port
17 // Watch: NOWDT - neni watchog 17 // Watch: NOWDT - neni watchog
18 // WDT - je watchdog 18 // WDT - je watchdog
19 // PUT: NOPUT - neni power up timer 19 // PUT: NOPUT - neni power up timer
20 // PUT - je power up timer 20 // PUT - je power up timer
21 // MCLR: MCLR - RA5/MCLR je MCLR 21 // MCLR: MCLR - RA5/MCLR je MCLR
22 // NOMCLR - RA5/MCLR je IO port 22 // NOMCLR - RA5/MCLR je IO port
23 // BOR: BROWNOUT - BOR povolen 23 // BOR: BROWNOUT - BOR povolen
24 // NOBROWNOUT - BOR zakazan 24 // NOBROWNOUT - BOR zakazan
25 // LVP: LVP - RB3/PGM je PGM 25 // LVP: LVP - RB3/PGM je PGM
26 // NOLVP - RB3/PGM je IO port 26 // NOLVP - RB3/PGM je IO port
27 // CPD: CPD - je ochrana EEPROM 27 // CPD: CPD - je ochrana EEPROM
28 // NOCPD - neni ochrana EEPROM 28 // NOCPD - neni ochrana EEPROM
29 // WRT WRT - zakaz zapisu do pameti programu 29 // WRT WRT - zakaz zapisu do pameti programu
30 // NOWRT - povolen zapis do pameti programu 30 // NOWRT - povolen zapis do pameti programu
31 // DEBUG: DEBUG - RB6 a RB7 jsou ICD port 31 // DEBUG: DEBUG - RB6 a RB7 jsou ICD port
32 // NODEBUG - RB6 a RB7 jsou IO port 32 // NODEBUG - RB6 a RB7 jsou IO port
33 // CCPMX: CCPB0 - CCP/PWM na RB0 33 // CCPMX: CCPB0 - CCP/PWM na RB0
34 // CCPB3 - CCP/PWM na RB3 34 // CCPB3 - CCP/PWM na RB3
35 // CP: PROTECT - pamet programu je chranena 35 // CP: PROTECT - pamet programu je chranena
36 // NOPROTECT - pamet programu neni chranena 36 // NOPROTECT - pamet programu neni chranena
37 // 37 //
38   38  
39 ////////////////////////////////////////////////////////////////// I/O 39 ////////////////////////////////////////////////////////////////// I/O
40 // Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(), 40 // Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
41 // PORT_B_PULLUPS(), INPUT(), 41 // PORT_B_PULLUPS(), INPUT(),
42 // OUTPUT_LOW(), OUTPUT_HIGH(), 42 // OUTPUT_LOW(), OUTPUT_HIGH(),
43 // OUTPUT_FLOAT(), OUTPUT_BIT() 43 // OUTPUT_FLOAT(), OUTPUT_BIT()
44 // Constants used to identify pins in the above are: 44 // Constants used to identify pins in the above are:
45   45  
46   46  
47   47  
48 #define PIN_A0 40 48 #define PIN_A0 40
49 #define PIN_A1 41 49 #define PIN_A1 41
50 #define PIN_A2 42 50 #define PIN_A2 42
51 #define PIN_A3 43 51 #define PIN_A3 43
52 #define PIN_A4 44 52 #define PIN_A4 44
53 #define PIN_A5 45 53 #define PIN_A5 45
54 #define PIN_A6 46 54 #define PIN_A6 46
55 #define PIN_A7 47 55 #define PIN_A7 47
56   56  
57 #define PIN_B0 48 57 #define PIN_B0 48
58 #define PIN_B1 49 58 #define PIN_B1 49
59 #define PIN_B2 50 59 #define PIN_B2 50
60 #define PIN_B3 51 60 #define PIN_B3 51
61 #define PIN_B4 52 61 #define PIN_B4 52
62 #define PIN_B5 53 62 #define PIN_B5 53
63 #define PIN_B6 54 63 #define PIN_B6 54
64 #define PIN_B7 55 64 #define PIN_B7 55
65   65  
66 ////////////////////////////////////////////////////////////////// Useful defines 66 ////////////////////////////////////////////////////////////////// Useful defines
67 #define FALSE 0 67 #define FALSE 0
68 #define TRUE 1 68 #define TRUE 1
69   69  
70 #define BYTE int 70 #define BYTE int
71 #define BOOLEAN short int 71 #define BOOLEAN short int
72   72  
73 #define getc getch 73 #define getc getch
74 #define fgetc getch 74 #define fgetc getch
75 #define getchar getch 75 #define getchar getch
76 #define putc putchar 76 #define putc putchar
77 #define fputc putchar 77 #define fputc putchar
78 #define fgets gets 78 #define fgets gets
79 #define fputs puts 79 #define fputs puts
80   80  
81 ////////////////////////////////////////////////////////////////// Control 81 ////////////////////////////////////////////////////////////////// Control
82 // Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE() 82 // Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
83 // Constants returned from RESTART_CAUSE() are: 83 // Constants returned from RESTART_CAUSE() are:
84 #define WDT_FROM_SLEEP 0 84 #define WDT_FROM_SLEEP 0
85 #define WDT_TIMEOUT 8 85 #define WDT_TIMEOUT 8
86 #define MCLR_FROM_SLEEP 16 86 #define MCLR_FROM_SLEEP 16
87 #define NORMAL_POWER_UP 24 87 #define NORMAL_POWER_UP 24
88   88  
89   89  
90 ////////////////////////////////////////////////////////////////// Timer 0 90 ////////////////////////////////////////////////////////////////// Timer 0
91 // Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER0(), 91 // Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER0(),
92 // SET_TIMER0() or SET_RTCC(), 92 // SET_TIMER0() or SET_RTCC(),
93 // GET_TIMER0() or GET_RTCC() 93 // GET_TIMER0() or GET_RTCC()
94 // Constants used for SETUP_TIMER0() are: 94 // Constants used for SETUP_TIMER0() are:
95 #define RTCC_INTERNAL 0 95 #define RTCC_INTERNAL 0
96 #define RTCC_EXT_L_TO_H 32 96 #define RTCC_EXT_L_TO_H 32
97 #define RTCC_EXT_H_TO_L 48 97 #define RTCC_EXT_H_TO_L 48
98   98  
99 #define RTCC_DIV_1 8 99 #define RTCC_DIV_1 8
100 #define RTCC_DIV_2 0 100 #define RTCC_DIV_2 0
101 #define RTCC_DIV_4 1 101 #define RTCC_DIV_4 1
102 #define RTCC_DIV_8 2 102 #define RTCC_DIV_8 2
103 #define RTCC_DIV_16 3 103 #define RTCC_DIV_16 3
104 #define RTCC_DIV_32 4 104 #define RTCC_DIV_32 4
105 #define RTCC_DIV_64 5 105 #define RTCC_DIV_64 5
106 #define RTCC_DIV_128 6 106 #define RTCC_DIV_128 6
107 #define RTCC_DIV_256 7 107 #define RTCC_DIV_256 7
108   108  
109   109  
110 #define RTCC_8_BIT 0 110 #define RTCC_8_BIT 0
111   111  
112 // Constants used for SETUP_COUNTERS() are the above 112 // Constants used for SETUP_COUNTERS() are the above
113 // constants for the 1st param and the following for 113 // constants for the 1st param and the following for
114 // the 2nd param: 114 // the 2nd param:
115   115  
116 ////////////////////////////////////////////////////////////////// WDT 116 ////////////////////////////////////////////////////////////////// WDT
117 // Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above) 117 // Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
118 // RESTART_WDT() 118 // RESTART_WDT()
119 // 119 //
120 #define WDT_18MS 8 120 #define WDT_18MS 8
121 #define WDT_36MS 9 121 #define WDT_36MS 9
122 #define WDT_72MS 10 122 #define WDT_72MS 10
123 #define WDT_144MS 11 123 #define WDT_144MS 11
124 #define WDT_288MS 12 124 #define WDT_288MS 12
125 #define WDT_576MS 13 125 #define WDT_576MS 13
126 #define WDT_1152MS 14 126 #define WDT_1152MS 14
127 #define WDT_2304MS 15 127 #define WDT_2304MS 15
128   128  
129 ////////////////////////////////////////////////////////////////// Timer 1 129 ////////////////////////////////////////////////////////////////// Timer 1
130 // Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1 130 // Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
131 // Constants used for SETUP_TIMER_1() are: 131 // Constants used for SETUP_TIMER_1() are:
132 // (or (via |) together constants from each group) 132 // (or (via |) together constants from each group)
133 #define T1_DISABLED 0 133 #define T1_DISABLED 0
134 #define T1_INTERNAL 0x85 134 #define T1_INTERNAL 0x85
135 #define T1_EXTERNAL 0x87 135 #define T1_EXTERNAL 0x87
136 #define T1_EXTERNAL_SYNC 0x83 136 #define T1_EXTERNAL_SYNC 0x83
137   137  
138 #define T1_CLK_OUT 8 138 #define T1_CLK_OUT 8
139   139  
140 #define T1_DIV_BY_1 0 140 #define T1_DIV_BY_1 0
141 #define T1_DIV_BY_2 0x10 141 #define T1_DIV_BY_2 0x10
142 #define T1_DIV_BY_4 0x20 142 #define T1_DIV_BY_4 0x20
143 #define T1_DIV_BY_8 0x30 143 #define T1_DIV_BY_8 0x30
144   144  
145 ////////////////////////////////////////////////////////////////// Timer 2 145 ////////////////////////////////////////////////////////////////// Timer 2
146 // Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2 146 // Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
147 // Constants used for SETUP_TIMER_2() are: 147 // Constants used for SETUP_TIMER_2() are:
148 #define T2_DISABLED 0 148 #define T2_DISABLED 0
149 #define T2_DIV_BY_1 4 149 #define T2_DIV_BY_1 4
150 #define T2_DIV_BY_4 5 150 #define T2_DIV_BY_4 5
151 #define T2_DIV_BY_16 6 151 #define T2_DIV_BY_16 6
152   152  
153 ////////////////////////////////////////////////////////////////// CCP 153 ////////////////////////////////////////////////////////////////// CCP
154 // CCP Functions: SETUP_CCPx, SET_PWMx_DUTY 154 // CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
155 // CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH 155 // CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
156 // Constants used for SETUP_CCPx() are: 156 // Constants used for SETUP_CCPx() are:
157 #define CCP_OFF 0 157 #define CCP_OFF 0
158 #define CCP_CAPTURE_FE 4 158 #define CCP_CAPTURE_FE 4
159 #define CCP_CAPTURE_RE 5 159 #define CCP_CAPTURE_RE 5
160 #define CCP_CAPTURE_DIV_4 6 160 #define CCP_CAPTURE_DIV_4 6
161 #define CCP_CAPTURE_DIV_16 7 161 #define CCP_CAPTURE_DIV_16 7
162 #define CCP_COMPARE_SET_ON_MATCH 8 162 #define CCP_COMPARE_SET_ON_MATCH 8
163 #define CCP_COMPARE_CLR_ON_MATCH 9 163 #define CCP_COMPARE_CLR_ON_MATCH 9
164 #define CCP_COMPARE_INT 0xA 164 #define CCP_COMPARE_INT 0xA
165 #define CCP_COMPARE_RESET_TIMER 0xB 165 #define CCP_COMPARE_RESET_TIMER 0xB
166 #define CCP_PWM 0xC 166 #define CCP_PWM 0xC
167 #define CCP_PWM_PLUS_1 0x1c 167 #define CCP_PWM_PLUS_1 0x1c
168 #define CCP_PWM_PLUS_2 0x2c 168 #define CCP_PWM_PLUS_2 0x2c
169 #define CCP_PWM_PLUS_3 0x3c 169 #define CCP_PWM_PLUS_3 0x3c
170 long CCP_1; 170 long CCP_1;
171 #byte CCP_1 = 0x15 171 #byte CCP_1 = 0x15
172 #byte CCP_1_LOW= 0x15 172 #byte CCP_1_LOW= 0x15
173 #byte CCP_1_HIGH= 0x16 173 #byte CCP_1_HIGH= 0x16
174 ////////////////////////////////////////////////////////////////// COMP 174 ////////////////////////////////////////////////////////////////// COMP
175 // Comparator Variables: C1OUT, C2OUT 175 // Comparator Variables: C1OUT, C2OUT
176 // Constants used in setup_comparators() are: 176 // Constants used in setup_comparators() are:
177 #define A0_A3_A1_A2 4 177 #define A0_A3_A1_A2 4
178 #define A0_A2_A1_A2 3 178 #define A0_A2_A1_A2 3
179 #define NC_NC_A1_A2 5 179 #define NC_NC_A1_A2 5
180 #define NC_NC_NC_NC 7 180 #define NC_NC_NC_NC 7
181 #define A0_VR_A1_VR 2 181 #define A0_VR_A1_VR 2
182 #define A3_VR_A2_VR 10 182 #define A3_VR_A2_VR 10
183 #define A0_A2_A1_A2_OUT_ON_A3_A4 6 183 #define A0_A2_A1_A2_OUT_ON_A3_A4 6
184 #define A3_A2_A1_A2 9 184 #define A3_A2_A1_A2 9
185   185  
186 #bit C1OUT = 0x1f.6 186 #bit C1OUT = 0x1f.6
187 #bit C2OUT = 0x1f.7 187 #bit C2OUT = 0x1f.7
188   188  
189 ////////////////////////////////////////////////////////////////// VREF 189 ////////////////////////////////////////////////////////////////// VREF
190 // Constants used in setup_vref() are: 190 // Constants used in setup_vref() are:
191 #define VREF_LOW 0xa0 191 #define VREF_LOW 0xa0
192 #define VREF_HIGH 0x80 192 #define VREF_HIGH 0x80
193 #define VREF_A2 0x40 193 #define VREF_A2 0x40
194   194  
195 ////////////////////////////////////////////////////////////////// INT 195 ////////////////////////////////////////////////////////////////// INT
196 // Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(), 196 // Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
197 // EXT_INT_EDGE() 197 // EXT_INT_EDGE()
198 // 198 //
199 // Constants used in EXT_INT_EDGE() are: 199 // Constants used in EXT_INT_EDGE() are:
200 #define L_TO_H 0x40 200 #define L_TO_H 0x40
201 #define H_TO_L 0 201 #define H_TO_L 0
202 // Constants used in ENABLE/DISABLE_INTERRUPTS() are: 202 // Constants used in ENABLE/DISABLE_INTERRUPTS() are:
203 #define GLOBAL 0x0BC0 203 #define GLOBAL 0x0BC0
204 #define INT_RTCC 0x0B20 204 #define INT_RTCC 0x0B20
205 #define INT_RB 0x0B08 205 #define INT_RB 0x0B08
206 #define INT_EXT 0x0B10 206 #define INT_EXT 0x0B10
207 #define INT_TBE 0x8C10 207 #define INT_TBE 0x8C10
208 #define INT_RDA 0x8C20 208 #define INT_RDA 0x8C20
209 #define INT_TIMER1 0x8C01 209 #define INT_TIMER1 0x8C01
210 #define INT_TIMER2 0x8C02 210 #define INT_TIMER2 0x8C02
211 #define INT_CCP1 0x8C04 211 #define INT_CCP1 0x8C04
212 #define INT_SSP 0x8C08 212 #define INT_SSP 0x8C08
213 #define INT_COMP 0x8D40 213 #define INT_COMP 0x8D40
214 #define INT_EEPROM 0x8D10 214 #define INT_EEPROM 0x8D10
215 #define INT_TIMER0 0x0B20 215 #define INT_TIMER0 0x0B20
216   216  
217 // Definice reistru pro pristup k EEPROM 217 // Definice reistru pro pristup k EEPROM
218 #define EEDATA 0x010C 218 #define EEDATA 0x010C
219 #define EEADR 0x010D 219 #define EEADR 0x010D
220 #define EEDATAH 0x010E 220 #define EEDATAH 0x010E
221 #define EEADRH 0x010F 221 #define EEADRH 0x010F
222 #define EECON1 0x018C 222 #define EECON1 0x018C
223 #define EECON1_RD 0 223 #define EECON1_RD 0
224 #define EECON1_WR 1 224 #define EECON1_WR 1
225 #define EECON1_WREN 2 225 #define EECON1_WREN 2
226 #define EECON1_WRERR 3 226 #define EECON1_WRERR 3
227 #define EECON1_FREE 4 227 #define EECON1_FREE 4
228 #define EECON1_EEPGD 7 228 #define EECON1_EEPGD 7
229 #define EECON2 0x018D 229 #define EECON2 0x018D
230 #define PIR2 0x000D 230 #define PIR2 0x000D
231 #define PIR2_EEIF 4 231 #define PIR2_EEIF 4
232 #define PIE2 0x008D 232 #define PIE2 0x008D
233 #define PIR2_EEIE 4 233 #define PIR2_EEIE 4
234   234  
235 // Definice pro AD prevodnik 235 // Definice pro AD prevodnik
236 #define ADCON0 0x1F 236 #define ADCON0 0x1F
237 #define ADCON1 0x9F 237 #define ADCON1 0x9F
238 #define ADRESH 0x1E 238 #define ADRESH 0x1E
239 #define ADRESL 0x9E 239 #define ADRESL 0x9E
240 #define ANSEL 0x9B 240 #define ANSEL 0x9B
241   241  
242 // Definice pro casovac a PWM 242 // Definice pro casovac a PWM
243 #define PR2 0x92 243 #define PR2 0x92
244 #define T2CON 0x12 244 #define T2CON 0x12
245 #define CCP1CON 0x17 245 #define CCP1CON 0x17
246 #define CCPR1L 0x15 246 #define CCPR1L 0x15
247   247  
248 // Definice pro komparator 248 // Definice pro komparator
249 #define CMCON 0x9C 249 #define CMCON 0x9C
250   250  
251 // Definice pro preruseni 251 // Definice pro preruseni
252 #define INTCON 0x0B 252 #define INTCON 0x0B
253 #bit GIE = INTCON.7 253 #bit GIE = INTCON.7
254 #bit PEIE = INTCON.6 254 #bit PEIE = INTCON.6
255 #bit TMR0IE = INTCON.5 255 #bit TMR0IE = INTCON.5
256 #bit INTE = INTCON.4 256 #bit INTE = INTCON.4
257 #bit RBIE = INTCON.3 257 #bit RBIE = INTCON.3
258 #bit TMR0IF = INTCON.2 258 #bit TMR0IF = INTCON.2
259 #bit INTF = INTCON.1 259 #bit INTF = INTCON.1
260 #bit RBIF = INTCON.0 260 #bit RBIF = INTCON.0
261   261  
262 #define PIE1 0x8C 262 #define PIE1 0x8C
263 #bit ADIE = PIE1.6 263 #bit ADIE = PIE1.6
264 #bit RCIE = PIE1.5 264 #bit RCIE = PIE1.5
265 #bit TXIE = PIE1.4 265 #bit TXIE = PIE1.4
266 #bit SSPIE = PIE1.3 266 #bit SSPIE = PIE1.3
267 #bit CCP1IE = PIE1.2 267 #bit CCP1IE = PIE1.2
268 #bit TMR2IE = PIE1.1 268 #bit TMR2IE = PIE1.1
269 #bit TMR1IE = PIE1.0 269 #bit TMR1IE = PIE1.0
270   270  
271 // Porty 271 // Porty
272 #define PORTA 0x05 272 #define PORTA 0x05
273 #define PORTB 0x06 273 #define PORTB 0x06
274 #define TRISA 0x85 274 #define TRISA 0x85
275 #define TRISB 0x86 275 #define TRISB 0x86
276   276  
277 #list 277 #list