You may want to wire it exactly like the drawing for testing purposes.
You may want to wire it exactly like the drawing for testing purposes.
alright, ive spent some more time on this, with my new lcd. redid the circuit to the schematic posted, still not working for me, it seems it is not writing at all,
do i need to set trisb to something? thats my current line of thought,
thx
Usually you don't need to set TRIS for those built-in command like SERIN/SEROUT/LCDOUT and of course for I2CREAD/I2CWRITE.
For the last, TRIS will change depending if you read ar write from an external I2C device.
What about your whole stuff??? schematic, Parts, Code???
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I think you should go back up and take another look at Ralph's post.
I know you had an LCD problem at the time, so you may have overlooked it, but it does have 2 important points.
Most important is the declarations of (sda and scl). Originally you had ...
sda var byte
scl var byte
. . .
sda=PORTB.0
scl=PORTB.1
While it may seem that this is assigning PORTB.0 to the sda variable, it doesn't work that way. What it really does is Read PORTB.0 (which is 1 due to the Pull-up resistor) then place the value in sda. Then when you try to use sda, it get's interpreted as a Pin Number (0-15). A 1 as a Pin Number points to PORTB.1
The same goes for scl, so both sda and scl will end up pointing to PORTB.1
The second big point was mentioned by Ben. The address of a 64Kx8 EEPROM has to be a WORD sized variable, not BYTE sized.
A third point that's not as critical, is shown in ralph's example. You only need to have 1 Control Byte. PBP automatically adjusts the value of the control byte depending on whether iit's a Read or a Write operation. The manual specifically says to leave bit 0 "Clear".
Oh yeah, a small typo, it should have been Serout2, that's why you got the compiler error previously.
HTH,
Darrel
hey! its working,
the problem i was having was in declaring tris when reading/writing to the memory. ive got it working now and am very happy. thankyou all for the help, heres my current code,
trisb=%00000010 'read i comment one out
'trisb=%00000001 'write
addr var byte
sda var PORTB.0
scl var PORTB.1
cont con %10100000
x var byte 'test data
y var byte 'read data
'x=%00000001 'test data is the number 0'
addr=0
loop:
'I2Cwrite sda,scl,cont,(addr),[x] 'comment out when reading
'pause 20
i2Cread sda,scl,cont,addr,[y] 'should read the data
pause 20
serout portb.2,4,[254,1]
serout Portb.2,4,["y=",#y," x=",#x," a=",#addr] 'visual verification
addr=addr+1
'x=x+%00000001
if addr=255 then end
goto loop
end
I have used external I2C EEProm on a number of projects and have NEVER had to change the TRIS statement to get things to work. Also you STILL have you address variable as a byte, it needs to be a word.
There is still something horribly wrong with either the software or hardware.
Last edited by DynamoBen; - 23rd June 2005 at 19:45.
Bookmarks