AIW128ProGuy
New Member
Hello,
I am trying to simply write data to an EEPROM and read it back, however I am having problems with that simple task. My microcontroller is the PIC 12F629 and the EEPROM is the 24AA00. I am using PicBasic Pro Compiler v2.43. My code is below:
Include "modedefs.bas"
W0 con 8
B0 var byte
I2CWRITE 0,1,$A0,0,[W0]
pause 10
I2CREAD 0,1,$A1,0,[B0]
If (B0 = 8) Then
High 5
Else
High 4
Endif
End
The problem is that no matter what I try, I2CREAD only returns a value of zero. The Data Pin is pin 0 and the Clock pin is pin 1. The control byte is '1010xxx0' for write and '1010xxx1' for read. I know that data is being sent because I took a multimeter to it and the voltage is definately changing on both the lines. Also, I included a label during the troubleshooting that would jump if no acknowledgement bit was sent...but it didn't jump. Thus leading me to believe that the EEPROM is getting the data and acknowledging it...but still returning all zeros. If you can help me out, I must have just messed up the syntax or something. Thanks.
** Chris **
I am trying to simply write data to an EEPROM and read it back, however I am having problems with that simple task. My microcontroller is the PIC 12F629 and the EEPROM is the 24AA00. I am using PicBasic Pro Compiler v2.43. My code is below:
Include "modedefs.bas"
W0 con 8
B0 var byte
I2CWRITE 0,1,$A0,0,[W0]
pause 10
I2CREAD 0,1,$A1,0,[B0]
If (B0 = 8) Then
High 5
Else
High 4
Endif
End
The problem is that no matter what I try, I2CREAD only returns a value of zero. The Data Pin is pin 0 and the Clock pin is pin 1. The control byte is '1010xxx0' for write and '1010xxx1' for read. I know that data is being sent because I took a multimeter to it and the voltage is definately changing on both the lines. Also, I included a label during the troubleshooting that would jump if no acknowledgement bit was sent...but it didn't jump. Thus leading me to believe that the EEPROM is getting the data and acknowledging it...but still returning all zeros. If you can help me out, I must have just messed up the syntax or something. Thanks.
** Chris **