This code works, if there is a number [99] or whatever in the write loop
If I modify that part to look like
I2CWRITE DPIN,CPIN,$A0,B0,[B1]
or any other variable instead of B1
all zeros get written into there, instead of actual variable value.
what code ?
minimal, complete and verifiable example MCVE , its not hard
this code
Code:
'* pic16f1825 : eprom addr =$a0 #CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_ON & _LVP_OFF
#ENDCONFIG
DEFINE OSC 32
OSCCON=$70
ANSELA=0
ANSELC=0
trisa.0=0
DEFINE I2C_SLOW 1
ANSELA = 0
B0 Var word
b2 var byte
X var byte
SCL var Porta.2
SDA var Porta.1
lata.0=1
DEFINE DEBUG_REG PORTA
DEFINE DEBUG_BIT 0 ; if not used for pwr
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
pause 2000
Debug 13,10,"Start",13 ,10
clear
For B0 = 0 To 15
b2=99+b0
I2CWRITE sda,scl,$A0,B0,[b2]
Pause 10 '
Next B0
pause 100
mainloop:
For B0 = 0 To 15
I2CREAD sda,scl,$A0,B0,[X]
debug 13,10, dec b0, " ", dec X
Next B0
pause 1000
Goto mainloop
end
produces as expected
Code:
Start
0 99
1 100
2 101
3 102
4 103
5 104
6 105
7 106
8 107
9 108
10 109
11 110
12 111
13 112
14 113
15 114
Bookmarks