OK, a bit more explanation.
I DO have the DEFINE I2C_SLOW 1 in my header,
Also,
The logical OR is to set the actual device address.
The "identifier" address of the PCF 8591 is %1001xxxy,
where "xxx" = the sub-address (as set by the 3 hardware
addressing pins), and "y" is the Read/Write bit. I have to shift
the sub-address (or hardware address) left with the << 1
to align it properly.
So, with my ORing statement, I'm actually sending
%10010000
(the chip has all 3 hardware address pins grounded)
Then I'm sending $44, which is supposed to be the control byte,
Then a data byte of "0", to tell it to start at channel "0"
The datasheet says $44 is the command to put it in the "auto-
increment" mode with "internal oscillator". After that, all you are supposed to have to do is read the chip.
A READ is supposed to give me all 4 channels at once.
I2CREAD PORTC.4,PORTC.5,DevAddr,[PSByte1,PSByte2,PSByte3,PSByte4]
The chip doesn't care what I call the bytes.
If any of this isn't correct, please tell me. Maybe that will help me
solve my problem.
Charles Linquist
Hi Charles,
Isn't the "Write" DevAddr suppose to be different than the "Read" address with the LSB being a "0" for write operation and a "1" for a read operation?
Thank you for the explanation of the ORing. I'm learning more here!
BobK
PBP automatically changes bit0 in the string. It handles the differences between WRITE and READ.
Charles Linquist
Ah...and I thought for sure I had it.
But another idea hit me looking thru the code...
You've got the R/W set to 0, should be a 1 for a read and 0 for a write.
Maybe, maybe not. Seems like that's the way it is for the other eeprom's I use.
I'm a bit late on the refresh button I'm thinking! You guys already got it...
Last edited by skimask; - 28th March 2007 at 03:32. Reason: Day late dollar short!
Check the PBP mqnual. PBP *AUTOMATICALLY* sets the LSbit to the
correct value. That is, the I2CREAD instruction FORCES the bit to "1"
and I2CWRITE FORCES it to "0". Try it in your code, and you will find
that it works.
Charles Linquist
Hi,
Have you tried the DEFINE I2C_HOLD 1 in your prog ? Any difference using or not using it ?
Regards
Sougata
Bookmarks