Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/i2c_eeprom.asm @ 573:77c8ff191cd7
Preparations for third bank of Custom Functions
author | heinrichsweikamp |
---|---|
date | Sat, 21 Apr 2012 12:09:37 +0200 |
parents | a587f491693d |
children | 16f4eafc197e |
comparison
equal
deleted
inserted
replaced
572:80a1d2d5a9ee | 573:77c8ff191cd7 |
---|---|
11 ; GNU General Public License for more details. | 11 ; GNU General Public License for more details. |
12 ; You should have received a copy of the GNU General Public License | 12 ; You should have received a copy of the GNU General Public License |
13 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 ; along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 ; provides routines for external EEPROM via I2C | 14 ; provides routines for external EEPROM via I2C |
15 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | 15 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com |
16 ; written: 10/30/05 | 16 ; written: 051030 |
17 ; last updated: 08/21/06 | 17 ; last updated: 120421 |
18 ; known bugs: | 18 ; known bugs: |
19 ; ToDo: use 2nd 32KB from external EEPROM for something | 19 ; ToDo: |
20 | 20 |
21 incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" | 21 incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" |
22 movlw ext_ee_temp1 | 22 movlw ext_ee_temp1 |
23 call incf_eeprom_address0 | 23 call incf_eeprom_address0 |
24 endm | 24 endm |
58 movlw d'1' ; increase address | 58 movlw d'1' ; increase address |
59 addwf eeprom_address+0,F | 59 addwf eeprom_address+0,F |
60 movlw d'0' | 60 movlw d'0' |
61 addwfc eeprom_address+1,F | 61 addwfc eeprom_address+1,F |
62 return | 62 return |
63 ; btfss eeprom_address+1,7 ; at address 8000? | 63 |
64 ; return ; no, return | |
65 ; | |
66 ; clrf eeprom_address+0 ; Clear eeprom address | |
67 ; clrf eeprom_address+1 | |
68 ; return | |
69 ; | |
70 write_external_eeprom_block: ; Writes a block of 64Byte (one page in external EEPROM without stop condition | 64 write_external_eeprom_block: ; Writes a block of 64Byte (one page in external EEPROM without stop condition |
71 #ifdef TESTING | 65 #ifdef TESTING |
72 ; When Simulating with MPLabSIM, there is no way to emulate external EEPROM... | 66 ; When Simulating with MPLabSIM, there is no way to emulate external EEPROM... |
73 return | 67 return |
74 #endif | 68 #endif |
82 movlw d'0' ; increase address | 76 movlw d'0' ; increase address |
83 incf eeprom_address+0,F | 77 incf eeprom_address+0,F |
84 addwfc eeprom_address+1,F | 78 addwfc eeprom_address+1,F |
85 return | 79 return |
86 | 80 |
87 ; btfss eeprom_address+1,7 ; at address 8000 | |
88 ; return ; no, return | |
89 ; | |
90 ; clrf eeprom_address+0 ; Clear eeprom address | |
91 ; clrf eeprom_address+1 | |
92 ; return | |
93 I2CWRITE_BLOCK: | 81 I2CWRITE_BLOCK: |
94 movwf ext_ee_temp1 ; Data byte in WREG | 82 movwf ext_ee_temp1 ; Data byte in WREG |
95 bsf SSPCON2,SEN ; Start condition | 83 bsf SSPCON2,SEN ; Start condition |
96 rcall WaitMSSP | 84 rcall WaitMSSP |
97 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 | 85 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
238 movlw d'1' | 226 movlw d'1' |
239 addwf eeprom_address+0,F | 227 addwf eeprom_address+0,F |
240 movlw d'0' | 228 movlw d'0' |
241 addwfc eeprom_address+1,F | 229 addwfc eeprom_address+1,F |
242 return | 230 return |
243 ; btfss eeprom_address+1,7 ; at 0x8000? | |
244 ; return ; no, return | |
245 ; | |
246 ; clrf eeprom_address+0 ; Yes, clear address | |
247 ; clrf eeprom_address+1 | |
248 ; return | |
249 ; | |
250 I2CREAD3: ; block read start with automatic address increase | 231 I2CREAD3: ; block read start with automatic address increase |
251 rcall I2CREAD_COMMON | 232 rcall I2CREAD_COMMON |
252 ; no Stop condition here | 233 ; no Stop condition here |
253 bra I2CREAD2_2 | 234 bra I2CREAD2_2 |
254 | 235 |