comparison code_part1/OSTC_code_asm_part1/i2c_eeprom.asm @ 81:31fa973a70fd

Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
author JeanDo
date Mon, 06 Dec 2010 18:05:39 +0100
parents 263348f83485
children 3e351e25f5d1
comparison
equal deleted inserted replaced
80:d2d7cb96100d 81:31fa973a70fd
68 68
69 69
70 write_external_eeprom: ; data in WREG 70 write_external_eeprom: ; data in WREG
71 ; increase address eeprom_address+0:eeprom_address+1 after write 71 ; increase address eeprom_address+0:eeprom_address+1 after write
72 ; with banking after 7FFF 72 ; with banking after 7FFF
73 #ifdef TESTING
74 ; When Simulating with MPLabSIM, there is no way to emulate external EEPROM...
75 return
76 #endif
77
73 rcall I2CWRITE ; writes WREG into EEPROM@eeprom_address 78 rcall I2CWRITE ; writes WREG into EEPROM@eeprom_address
74 movlw d'1' ; increase address 79 movlw d'1' ; increase address
75 addwf eeprom_address+0,F 80 addwf eeprom_address+0,F
76 movlw d'0' 81 movlw d'0'
77 addwfc eeprom_address+1,F 82 addwfc eeprom_address+1,F
82 clrf eeprom_address+0 ; Clear eeprom address 87 clrf eeprom_address+0 ; Clear eeprom address
83 clrf eeprom_address+1 88 clrf eeprom_address+1
84 bsf eeprom_overflow ; and set overflow bit 89 bsf eeprom_overflow ; and set overflow bit
85 return 90 return
86 write_external_eeprom_block: ; Writes a block of 64Byte (one page in external EEPROM without stop condition 91 write_external_eeprom_block: ; Writes a block of 64Byte (one page in external EEPROM without stop condition
92 #ifdef TESTING
93 ; When Simulating with MPLabSIM, there is no way to emulate external EEPROM...
94 return
95 #endif
96
87 btfsc eeprom_blockwrite ; Blockwrite continue? 97 btfsc eeprom_blockwrite ; Blockwrite continue?
88 rcall I2CWRITE_BLOCK2 98 rcall I2CWRITE_BLOCK2
89 btfss eeprom_blockwrite ; Blockwrite start? 99 btfss eeprom_blockwrite ; Blockwrite start?
90 rcall I2CWRITE_BLOCK 100 rcall I2CWRITE_BLOCK
91 bsf eeprom_blockwrite ; After the start, do blockwriting for the next 63Bytes! 101 bsf eeprom_blockwrite ; After the start, do blockwriting for the next 63Bytes!
122 rcall I2C_WaitforACK 132 rcall I2C_WaitforACK
123 return 133 return
124 134
125 135
126 get_free_EEPROM_location: ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE 136 get_free_EEPROM_location: ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE
137
138 #ifdef TESTING
139 ; In testing mode, find 0x100 (internal EEPROM) as the first free location...
140 clrf eeprom_address+0 ; Not found in entire EEPROM, set to address 0
141 movlw 0x1
142 movwf eeprom_address+1
143 return
144 #endif
145
127 clrf ext_ee_temp1 ; low address counter 146 clrf ext_ee_temp1 ; low address counter
128 clrf ext_ee_temp2 ; high address counter 147 clrf ext_ee_temp2 ; high address counter
129 bcf second_FD ; clear flags 148 bcf second_FD ; clear flags
130 bcf first_FD 149 bcf first_FD
131 get_free_EEPROM_location3: 150 get_free_EEPROM_location3: