"ep_address" instead of "eep_address" didn't generate an error because it is a paste error only. I selected the block starting from the 2nd chara of the line, so it is alright, the variable name is right.
I changed slightly the code:
eep_address VAR WORD
instead of BYTE
and:
I added:
ADCON0.0 = 0 'turn adcon off
Things I wanted to do:
- solder a 8 pins socket on a protoboard instead of breadboard and solder connexions
-> DONE
- use 2k wpu only on sda instead of a 4.7k wpu on each scl and sda
-> DONE, but I used 2K on each of the SCL and SDA pins
- swap with another pic16f690 in case the one i use is defect
-> DONE
- swap with another 24lc08b in case the one i use is defect
-> DONE
- try a huge pause 50 instead of pause 5 after the i2cwrite in case it is a timing problem
-> DONE
- declare the eeprom address variable as a word instead of as a byte
->DONE
- declare "eep_address" instead of "ep_address" (i wonder how i didn't see this typing error!)
-> DONE, no error there in fact
code is:
Code:
'routine that checks if the external eeprom (the mag) is connected to the supplier
'it writes than reads back the test value (33)
checkwrite = 33
eep_address = 0 'use storage byte 1 of 255 fo rthe test
LCDOUT $fe,1,"CTRLbyte:",#eep_control
PAUSE 2000
I2CWRITE PORTC.6,PORTC.7,eep_control,eep_address,[checkwrite] 'store maxitem value in the mag external EEPROM
PAUSE 50 'hadware dependent
LCDOUT $FE,1,"Wrote:",#checkwrite,"@",#eep_address
PAUSE 2000
I2CREAD PORTC.6,PORTC.7,eep_control,eep_address,[checkwrite] 'store maxitem value in the mag external EEPROM
LCDOUT $fe,1,"Read:",#checkwrite,"@",#eep_address
PAUSE 2000
IF (checkwrite != 33) then
LCDOUT $fe,1,"couldn't write"
PAUSE 4000
checkwrite = 0
GOTO endofroutine
ENDIF
checkwrite = 66
----------------------
RESULTS:
The output on LCD is:
"wrote:33@0"
"read:0@0"
"couldn'twrite"
So, back to the starting point but this time I have no idea what I could change.
Is it the wires length? Did I failed to set some registers? ...
I'm lost... And angry.
My circuit is useless if I can't write to external eeprom...
Bookmarks