Mercurial > public > hwos_code
annotate src/i2c.asm @ 160:99ac325586ce
BUGFIX: Fast diluent (w/o dive mode menu) change did not work correctly
author | heinrichsweikamp |
---|---|
date | Mon, 08 Sep 2014 15:39:41 +0200 |
parents | 683321c09cfa |
children | 30ebaf72170d |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File i2c.asm | |
4 ; | |
5 ; I2C Interface to HMC5883L and MMA8452Q | |
6 ; | |
7 ; HMC5883L's read address (8-Bit): 0x3D | |
8 ; HMC5883L's write address (8-Bit): 0x3C | |
9 ; | |
10 ; MMA8452Q's read address (8-Bit): 0x39 | |
11 ; MMA8452Q's write address (8-Bit): 0x38 | |
12 ; | |
13 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
14 ;============================================================================= | |
15 ; HISTORY | |
16 ; 2012-08-22 : [mH] Creation | |
17 | |
18 | |
19 #include "ostc3.inc" ; Mandatory header | |
20 #include "wait.inc" | |
113 | 21 #include "math.inc" |
22 | |
23 #DEFINE battery_offset .27302 ; 65536-(3,25Ah/0,085mAh) | |
24 #DEFINE battery_devider .382 ; 3,25Ah/0,085mAh/100 [%] | |
0 | 25 |
26 i2c CODE | |
27 | |
28 WaitMSSP: | |
29 decfsz i2c_temp,F ; check for timeout during I2C action | |
30 bra WaitMSSP2 | |
31 bra I2CFail ; timeout occured | |
32 WaitMSSP2: | |
33 btfss PIR1,SSPIF | |
34 bra WaitMSSP | |
35 clrf i2c_temp | |
36 bcf PIR1,SSPIF | |
37 nop | |
38 return | |
39 | |
40 I2C_WaitforACK: | |
41 btfss SSPCON2,ACKSTAT ; checks for ACK bit from slave | |
42 return | |
43 I2CFail: | |
44 rcall I2CReset ; I2C Reset | |
45 bcf PIR1,SSPIF | |
46 clrf i2c_temp | |
47 return | |
48 | |
49 I2CReset: ; Something went wrong (Slave holds SDA low?) | |
50 clrf SSP1CON1 ; wake-up slave and reset entire module | |
51 clrf SSP1CON2 | |
52 clrf SSP1STAT | |
53 bcf TRISC,3 ; SCL OUTPUT | |
54 bsf TRISC,4 ; SDA Input | |
55 bcf PORTC,3 | |
56 movlw d'9' | |
57 movwf i2c_temp ; clock-out 9 clock cycles manually | |
58 I2CReset_1: | |
59 bsf PORTC,3 ; SCL=1 | |
60 nop | |
61 nop | |
62 nop | |
63 nop | |
64 btfsc PORTC,4 ; SDA=1? | |
65 bra I2CReset_2 ; =1, SDA has been released from slave | |
66 bcf PORTC,3 ; SCL=0 | |
67 nop | |
68 nop | |
69 bcf PORTC,3 | |
70 nop | |
71 nop | |
72 decfsz i2c_temp,F | |
73 bra I2CReset_1 ; check for nine clock cycles | |
74 I2CReset_2: | |
75 bsf TRISC,3 ; SCL Input | |
76 clrf SSP1CON1 ; setup I²C Mode | |
77 WAITMS d'10' ; Reset-Timeout for I2C devices | |
78 movlw b'00000000' ; with slew rate control | |
79 movwf SSPSTAT | |
80 movlw b'00101000' | |
81 movwf SSP1CON1 | |
82 movlw b'00000000' | |
83 movwf SSP1CON2 | |
84 movlw 0x27 | |
85 movwf SSP1ADD | |
86 return | |
87 | |
88 I2C_TX: | |
89 movwf SSP1BUF | |
90 rcall WaitMSSP | |
91 bra I2C_WaitforACK ; Returns... | |
92 | |
93 I2C_TwoBytesRX_div16: ; Get two bytes and devide lo:hi/16 (signed) | |
94 rcall I2C_OneByteRX ; Get one byte | |
95 movff SSP1BUF,hi ; Data Byte | |
96 rcall I2C_OneByteRX ; Get one byte | |
97 movff SSP1BUF,lo ; Data Byte | |
98 I2C_TwoBytesRX_div16_2: ; devide lo:hi/16 (signed) only | |
99 bcf STATUS,C | |
100 btfsc hi,7 ; Copy sign bit to carry | |
101 bsf STATUS,C | |
102 rrcf hi ; /2 | |
103 rrcf lo | |
104 bcf STATUS,C | |
105 btfsc hi,7 ; Copy sign bit to carry | |
106 bsf STATUS,C | |
107 rrcf hi ; /4 | |
108 rrcf lo | |
109 bcf STATUS,C | |
110 btfsc hi,7 ; Copy sign bit to carry | |
111 bsf STATUS,C | |
112 rrcf hi ; /8 | |
113 rrcf lo | |
114 bcf STATUS,C | |
115 btfsc hi,7 ; Copy sign bit to carry | |
116 bsf STATUS,C | |
117 rrcf hi ; /16 | |
118 rrcf lo | |
119 return | |
120 | |
121 global I2C_RX_accelerometer | |
122 I2C_RX_accelerometer: | |
123 bsf SSP1CON2,SEN ; Start condition | |
124 rcall WaitMSSP | |
125 movlw 0x38 ; address | |
126 rcall I2C_TX | |
158 | 127 movlw 0x00 |
0 | 128 rcall I2C_TX |
129 bsf SSP1CON2,RSEN ; Repeated start condition (!) | |
130 rcall WaitMSSP | |
131 movlw 0x39 ; address | |
132 rcall I2C_TX | |
133 | |
158 | 134 rcall I2C_OneByteRX ; Get Status Byte |
135 movf SSP1BUF,W | |
136 | |
0 | 137 ; Chip orientation on the PCB requires |
138 ; Original = Corrected | |
139 ; x = -x | |
140 ; y = -y | |
141 ; z = -z | |
142 | |
143 rcall I2C_TwoBytesRX_div16 ; Get two bytes and devide /16 (signed) | |
144 comf hi ; 16bit sign change. | |
145 negf lo | |
146 btfsc STATUS,C ; Carry to propagate ? | |
147 incf hi,F ; YES: do it. | |
148 movff lo,accel_DX+0 | |
149 movff hi,accel_DX+1 ; Copy result | |
150 | |
151 rcall I2C_TwoBytesRX_div16 ; Get two bytes and devide /16 (signed) | |
152 comf hi ; 16bit sign change. | |
153 negf lo | |
154 btfsc STATUS,C ; Carry to propagate ? | |
155 incf hi,F ; YES: do it. | |
156 movff lo,accel_DY+0 | |
157 movff hi,accel_DY+1 ; Copy result | |
158 | |
159 rcall I2C_OneByteRX ; Get one byte | |
160 movff SSP1BUF,hi ; Data Byte | |
161 bsf SSP1CON2, RCEN ; Enable recieve mode | |
162 rcall WaitMSSP | |
163 ; According to datasheet there should be no Master Acknowlegde for the last Byte (accel_DZ+0)... | |
164 movff SSP1BUF,lo ; Data Byte | |
165 | |
166 rcall I2C_TwoBytesRX_div16_2; devide lo:hi/16 (signed) only | |
167 comf hi ; 16bit sign change. | |
168 negf lo | |
169 btfsc STATUS,C ; Carry to propagate ? | |
170 incf hi,F ; YES: do it. | |
171 movff lo,accel_DZ+0 | |
172 movff hi,accel_DZ+1 ; Copy result | |
173 | |
174 bsf SSP1CON2,PEN ; Stop condition | |
175 rcall WaitMSSP | |
176 return | |
177 | |
178 I2C_OneByteRX: | |
179 bsf SSP1CON2, RCEN ; Enable recieve mode | |
180 rcall WaitMSSP | |
181 bsf SSP1CON2,ACKEN ; Master acknowlegde | |
182 rcall WaitMSSP | |
183 return | |
184 | |
185 global I2C_RX_compass | |
186 I2C_RX_compass: | |
187 bsf SSP1CON2,SEN ; Start condition | |
188 rcall WaitMSSP | |
189 movlw 0x3C ; address | |
190 rcall I2C_TX | |
191 movlw 0x03 | |
192 rcall I2C_TX | |
193 bsf SSP1CON2,PEN ; Stop condition | |
194 rcall WaitMSSP | |
195 | |
196 bcf PIR1,SSPIF | |
197 bsf SSP1CON2,SEN ; Start condition | |
198 rcall WaitMSSP | |
199 movlw 0x3D ; address | |
200 rcall I2C_TX | |
201 | |
202 ; Compass IC sends data in following order: | |
203 ; x MSB | |
204 ; x LSB | |
205 ; z MSB | |
206 ; z LSB | |
207 ; y MSB | |
208 ; y LSB | |
209 | |
210 ; Chip orientation on the PCB requires | |
211 ; Original = Corrected | |
212 ; x = -y | |
213 ; z = z | |
214 ; y = x | |
215 | |
216 rcall I2C_OneByteRX ; Get one byte | |
217 movff SSP1BUF,compass_DY+1; Data Byte | |
218 rcall I2C_OneByteRX ; Get one byte | |
219 movff SSP1BUF,compass_DY+0; Data Byte | |
220 banksel compass_DY | |
221 comf compass_DY+1 ; 16bit sign change. | |
222 negf compass_DY+0 | |
223 btfsc STATUS,C ; Carry to propagate ? | |
224 incf compass_DY+1,F ; YES: do it. | |
225 banksel common | |
226 rcall I2C_OneByteRX ; Get one byte | |
227 movff SSP1BUF,compass_DZ+1; Data Byte | |
228 rcall I2C_OneByteRX ; Get one byte | |
229 movff SSP1BUF,compass_DZ+0; Data Byte | |
230 rcall I2C_OneByteRX ; Get one byte | |
231 movff SSP1BUF,compass_DX+1; Data Byte | |
232 bsf SSP1CON2, RCEN ; Enable recieve mode | |
233 rcall WaitMSSP | |
234 movff SSP1BUF,compass_DX+0; Data Byte | |
235 bsf SSP1CON2,PEN ; Stop condition | |
236 rcall WaitMSSP | |
237 return | |
238 | |
239 global I2C_init_compass | |
240 I2C_init_compass: | |
241 bsf SSP1CON2,SEN ; Start condition | |
242 rcall WaitMSSP | |
243 movlw 0x3C ; address | |
244 rcall I2C_TX | |
245 movlw 0x00 | |
246 rcall I2C_TX | |
247 ; movlw b'01101001' ; ConfigA: 3Hz, 8 Samples averaged, Test Mode (Positive Bias) | |
248 movlw b'01101000' ; ConfigA: 3Hz, 8 Samples averaged | |
249 rcall I2C_TX | |
20 | 250 bra I2C_init_compass_common |
251 | |
252 global I2C_init_compass_fast | |
253 I2C_init_compass_fast: | |
254 bsf SSP1CON2,SEN ; Start condition | |
255 rcall WaitMSSP | |
256 movlw 0x3C ; address | |
257 rcall I2C_TX | |
258 movlw 0x00 | |
259 rcall I2C_TX | |
260 movlw b'00111000' ; ConfigA: 75Hz, 2 Samples averaged | |
261 ; movlw b'00111001' ; ConfigA: 75Hz, 2 Samples averaged, Test Mode (Positive Bias) | |
262 rcall I2C_TX | |
263 I2C_init_compass_common: | |
18
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
264 movff opt_compass_gain,i2c_temp ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
265 swapf i2c_temp,F |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
266 comf i2c_temp,F |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
267 bcf STATUS,C |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
268 rlcf i2c_temp |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
269 movf i2c_temp,W |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
270 clrf i2c_temp |
0 | 271 rcall I2C_TX |
272 movlw b'00000000' ; Continous Mode | |
273 rcall I2C_TX | |
274 bsf SSP1CON2,PEN ; Stop condition | |
275 rcall WaitMSSP | |
276 bsf compass_enabled | |
277 return | |
278 | |
279 global I2C_sleep_compass | |
280 I2C_sleep_compass: | |
281 bsf SSP1CON2,SEN ; Start condition | |
282 rcall WaitMSSP | |
283 movlw 0x3C ; address | |
284 rcall I2C_TX | |
285 movlw 0x00 | |
286 rcall I2C_TX | |
287 movlw b'01101000' ; ConfigA | |
288 rcall I2C_TX | |
289 movlw b'00100000' ; ConfigB | |
290 rcall I2C_TX | |
291 movlw b'00000010' ; Idle Mode | |
292 rcall I2C_TX | |
293 bsf SSP1CON2,PEN ; Stop condition | |
294 rcall WaitMSSP | |
295 bcf compass_enabled | |
296 return | |
297 | |
298 | |
299 global I2C_init_accelerometer | |
300 I2C_init_accelerometer: | |
301 rcall I2C_sleep_accelerometer ; Regs can only be changed in St.By mode | |
302 | |
303 bsf SSP1CON2,SEN ; Start condition | |
304 rcall WaitMSSP | |
305 movlw 0x38 ; address | |
306 rcall I2C_TX | |
307 movlw 0x0E ; XYZ_DATA_CFG | |
308 rcall I2C_TX | |
309 movlw b'00000000' ; High pass Filter=0 , +/- 2g range | |
310 rcall I2C_TX | |
311 bsf SSP1CON2,PEN ; Stop condition | |
312 rcall WaitMSSP | |
313 | |
314 | |
315 bsf SSP1CON2,SEN ; Start condition | |
316 rcall WaitMSSP | |
317 movlw 0x38 ; address | |
318 rcall I2C_TX | |
319 movlw 0x2A ; CTRL_REG1 | |
320 rcall I2C_TX | |
321 ; movlw b'00110000' ; CTRL_REG1: 160ms data rate, St.By Mode | |
322 movlw b'00110100' ; CTRL_REG1: 160ms data rate, St.By Mode, reduced noise mode | |
323 rcall I2C_TX | |
324 movlw b'00000010' ; CTRL_REG2: High Res in Active mode | |
325 rcall I2C_TX | |
326 bsf SSP1CON2,PEN ; Stop condition | |
327 rcall WaitMSSP | |
328 | |
329 bsf SSP1CON2,SEN ; Start condition | |
330 rcall WaitMSSP | |
331 movlw 0x38 ; address | |
332 rcall I2C_TX | |
333 movlw 0x2A ; CTRL_REG1 | |
334 rcall I2C_TX | |
335 ; movlw b'00110001' ; CTRL_REG1: 160ms data rate, Active Mode | |
336 movlw b'00110101' ; CTRL_REG1: 160ms data rate, St.By Mode, reduced noise mode, Active Mode | |
337 rcall I2C_TX | |
338 bsf SSP1CON2,PEN ; Stop condition | |
339 rcall WaitMSSP | |
340 | |
341 return | |
342 | |
343 global I2C_sleep_accelerometer | |
344 I2C_sleep_accelerometer: | |
345 bsf SSP1CON2,SEN ; Start condition | |
346 rcall WaitMSSP | |
347 movlw 0x38 ; address | |
348 rcall I2C_TX | |
349 movlw 0x2A ; CTRL_REG1 | |
350 rcall I2C_TX | |
351 movlw b'00000000' ; St. By Mode | |
352 rcall I2C_TX | |
353 bsf SSP1CON2,PEN ; Stop condition | |
354 rcall WaitMSSP | |
355 return | |
356 | |
113 | 357 global lt2942_init |
358 lt2942_init: ; Setup Control register B | |
359 clrf i2c_temp | |
360 movlw 0x01 ; Point to control reg B | |
361 call I2C_TX_GAUGE | |
362 movlw b'11111000' ; Automatic conversion every two seconds | |
363 movff WREG, SSP1BUF ; Data Byte | |
364 rcall WaitMSSP | |
365 rcall I2C_WaitforACK | |
366 bsf SSP1CON2,PEN ; Stop condition | |
367 rcall WaitMSSP | |
368 return | |
369 | |
370 global lt2942_get_status | |
371 lt2942_get_status: ; Read status register | |
372 bcf c3_hardware ; Clear flag | |
373 clrf i2c_temp | |
374 movlw 0x00 ; Point to Status reg | |
375 call I2C_TX_GAUGE | |
376 call I2C_RX_GAUGE | |
377 movff SSP1BUF,WREG | |
378 btfss WREG,7 ; 2942 found? | |
379 bsf c3_hardware ; Yes, set flag | |
380 bsf SSP1CON2,PEN ; Stop condition | |
381 rcall WaitMSSP | |
382 return | |
383 | |
384 | |
385 global lt2942_get_voltage | |
386 lt2942_get_voltage: ; Read battery voltage registers | |
387 clrf i2c_temp | |
388 movlw 0x08 ; Point to voltage registers | |
389 call I2C_TX_GAUGE | |
390 call I2C_RX_GAUGE | |
391 bsf SSP1CON2,ACKEN ; Master acknowlegde | |
392 rcall WaitMSSP | |
393 movff SSP1BUF,xA+1 | |
394 bsf SSP1CON2, RCEN ; Enable recieve mode | |
395 rcall WaitMSSP | |
396 movff SSP1BUF,xA+0 | |
397 bsf SSP1CON2,PEN ; Stop condition | |
398 rcall WaitMSSP | |
399 | |
400 ; banksel common | |
401 ; xA:2 loaded with raw values | |
402 movlw LOW .6000 | |
403 movwf xB+0 | |
404 movlw HIGH .6000 | |
405 movwf xB+1 | |
406 call mult16x16 ;xA*xB=xC | |
407 | |
408 ; devide xC (32bit)/65535 for result in mV (16bit) | |
409 movlw .16 | |
410 movwf i2c_temp | |
411 lt2942_get_voltage2: | |
412 bcf STATUS,C | |
413 rrcf xC+3,F | |
414 rrcf xC+2,F | |
415 rrcf xC+1,F | |
416 rrcf xC+0,F | |
417 decfsz i2c_temp,F | |
418 bra lt2942_get_voltage2 | |
419 | |
420 ; Update battery voltage in mV | |
421 movff xC+1,batt_voltage+1 | |
422 movff xC+0,batt_voltage+0 | |
423 return | |
424 | |
425 ; global lt2942_get_temperature | |
426 ;lt2942_get_temperature: ; Read temperature registers | |
427 ; clrf i2c_temp | |
428 ; movlw 0x0C ; Point to temperature registers | |
429 ; call I2C_TX_GAUGE | |
430 ; call I2C_RX | |
431 ; bsf SSP1CON2,ACKEN ; Master acknowlegde | |
432 ; rcall WaitMSSP | |
433 ; movff SSP1BUF,xA+1 | |
434 ; bsf SSP1CON2, RCEN ; Enable recieve mode | |
435 ; rcall WaitMSSP | |
436 ; movff SSP1BUF,xA+0 | |
437 ; bsf SSP1CON2,PEN ; Stop condition | |
438 ; rcall WaitMSSP | |
439 ; | |
440 ;; banksel common | |
441 ; ; xA:2 loaded with raw values | |
442 ; movlw LOW .6000 | |
443 ; movwf xB+0 | |
444 ; movlw HIGH .6000 | |
445 ; movwf xB+1 | |
446 ; call mult16x16 ;xA*xB=xC | |
447 ; | |
448 ; ; devide xC (32bit)/65535 for result in 0.1K (16bit) | |
449 ; movlw .16 | |
450 ; movwf i2c_temp | |
451 ;lt2942_get_temperature2: | |
452 ; bcf STATUS,C | |
453 ; rrcf xC+3,F | |
454 ; rrcf xC+2,F | |
455 ; rrcf xC+1,F | |
456 ; rrcf xC+0,F | |
457 ; decfsz i2c_temp,F | |
458 ; bra lt2942_get_temperature2 | |
459 ; | |
460 ; movff xC+1,sub_a+1 | |
461 ; movff xC+0,sub_a+0 | |
462 ; movlw LOW .2731 ; Kelvin to Celcius offset | |
463 ; movwf sub_b+0 | |
464 ; movlw HIGH .2731 ; Kelvin to Celcius offset | |
465 ; movwf sub_b+1 | |
466 ; call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
467 ; | |
468 ; ; Update batttery_temperature in 0.1°C | |
469 ; movff sub_c+1,battery_temperature+1 | |
470 ; movff sub_c+0,battery_temperature+0 | |
471 ; return | |
472 | |
473 global lt2942_get_accumulated_charge | |
474 lt2942_get_accumulated_charge: ; Read accumulated charge and compute percent | |
475 clrf i2c_temp | |
476 movlw 0x02 ; Point to accumulated charge registers | |
477 call I2C_TX_GAUGE | |
478 call I2C_RX_GAUGE | |
479 bsf SSP1CON2,ACKEN ; Master acknowlegde | |
480 rcall WaitMSSP | |
481 movff SSP1BUF,sub_a+1 ; battery_acumulated_charge+1 | |
482 bsf SSP1CON2, RCEN ; Enable recieve mode | |
483 rcall WaitMSSP | |
484 movff SSP1BUF,sub_a+0 ; battery_acumulated_charge+0 | |
485 bsf SSP1CON2,PEN ; Stop condition | |
486 rcall WaitMSSP | |
487 | |
488 ; Compute batt_percent | |
489 ; charge-battery_offset/382 | |
490 movlw LOW battery_offset | |
491 movwf sub_b+0 | |
492 movlw HIGH battery_offset | |
493 movwf sub_b+1 | |
494 call subU16 ; sub_c = sub_a - sub_b (with signed values) | |
495 | |
496 clrf batt_percent ; Set to zero | |
497 btfsc neg_flag ; result negative? | |
498 return ; Yes, done. | |
499 | |
500 ; > Zero, set batt_percent properly | |
501 movff sub_c+0,xA+0 | |
502 movff sub_c+1,xA+1 | |
503 movlw LOW battery_devider | |
504 movwf xB+0 | |
505 movlw HIGH battery_devider | |
506 movwf xB+1 | |
507 call div16x16 ;xA/xB=xC with xA+0 as remainder, uses divB as temp variable | |
508 movff xC+0,batt_percent | |
509 return | |
510 | |
511 global lt2942_charge_done | |
512 lt2942_charge_done: ; Reset accumulating registers to 0xFFFF | |
513 clrf i2c_temp | |
514 movlw 0x02 ; Point to accumulated charge registers | |
515 call I2C_TX_GAUGE | |
516 movlw 0xFF | |
517 movff WREG, SSP1BUF ; Data Byte | |
518 rcall WaitMSSP | |
519 rcall I2C_WaitforACK | |
520 movlw 0xFF | |
521 movff WREG, SSP1BUF ; Data Byte | |
522 rcall WaitMSSP | |
523 rcall I2C_WaitforACK | |
524 bsf SSP1CON2,PEN ; Stop condition | |
525 rcall WaitMSSP | |
526 return | |
527 | |
528 I2C_TX_GAUGE: ; Sends a byte to the LT2942 Gauge IC | |
529 movwf i2c_temp+1 ; Data byte | |
530 bsf SSP1CON2,SEN ; Start condition | |
531 rcall WaitMSSP | |
532 movlw b'11001000' ; Address byte + Write bit | |
533 movwf SSP1BUF ; control byte | |
534 rcall WaitMSSP | |
535 rcall I2C_WaitforACK | |
536 movff i2c_temp+1, SSP1BUF ; Data Byte | |
537 rcall WaitMSSP | |
538 rcall I2C_WaitforACK | |
539 return | |
540 | |
541 I2C_RX_GAUGE: | |
542 bsf SSP1CON2,SEN ; Start condition | |
543 rcall WaitMSSP | |
544 movlw b'11001001' ; Address byte + Read bit | |
545 movwf SSP1BUF ; control byte | |
546 rcall WaitMSSP | |
547 rcall I2C_WaitforACK | |
548 bsf SSP1CON2, RCEN ; Enable recieve mode | |
549 rcall WaitMSSP | |
550 return | |
551 | |
552 | |
0 | 553 |
554 END |