Moreover,
The physical address has to be shifted left once (multiplied by 2) to cope with the I2C format. In my case the physical address is $2C : I have to pass $58 to I2CWRITE.
MikeBZH / F8DFN
Moreover,
The physical address has to be shifted left once (multiplied by 2) to cope with the I2C format. In my case the physical address is $2C : I have to pass $58 to I2CWRITE.
MikeBZH / F8DFN
Strange... I use PBP v2.50 I2C to talk to EEPROM 24LC64, DS1307 and MCP23008 and other devices on the same board and it all behaves as expected per the Manual...
Hi Melanie,
Please note that I use PBPL. Maybe the behaviour of this version is different from the others. I have no more time to make some comparison tests but I will do them when I come back from vacation by the end of August.
MikeBZH / F8DFN
Hi,
Coming back after some time spent with other business...
I have no more MAX517 in my circuit but the MCP23008 are still there and I need to use I2CWRITE and I2CREAD with them.
The issue is still there. I confirm that with my PBPL v2.50, I need to invert the address and the control fields and to multiply the address by 2 to make I2CWRITE work. And from the experiments done this morning I know that I need to do the same thing for I2CREAD !
Best regards
MikeBZH / F8DFN
Last edited by MikeBZH; - 11th January 2010 at 12:46.
MikeBZH, I hope you had a nice vacation in August... I have been currently using a pair of 24LC1025's to log data from my Solar Tracker which uses an 18F2620 running @ 40 Mhz. I have had no problem with them even in the below zero temperatures we have up here in Michigan...
I do not compile with PBPL as I have used the internal flash to about 3/4"s of its capacity. It's nice to see you back...
Dave Purola
N8NTA
Then you are doing something very strange in either your Hardware connections or in Software!I need to invert the address and the control fields and to multiply the address by 2
If fact, I believe you've not realised how the chip is to be addressed (refer to Datasheet 1.4.1). If you have GROUNDED pins A0,A1 and A2, then you would address the chip as $40, but if for example A1 and A2 are GROUNDED and you tie A0 to VDD, then you would address the chip as $42. Note that Bit 0 must be left alone, because it determines if this is a READ or WRITE operation!!!! YOU don't touch BIT-0, it is set for you elsewhere by the I2C commands (which also determines that your ADDRESS must be a BYTE VARIABLE and NOT a Constant).
I use MCP23008's in several designs with both 16F's and 18F's. PBP Ver 2.46 thru 2.50 has no problems and no issues and allows me to port software across several PIC families which may not have I2C hardware capability. I commonly mix MCP23008's with EEPROM's and RTC's all on the same bus, and up to five devices on the same bus pins are good with 4K7 Pull-Up's.
I2CWrite SDA,SCL,I2CAddress,I2CRegister,[I2CData]
Where I2CAddress, I2CRegister and I2CData are all BYTES and previously (for example)...
I2CAddress=$42 ' Hardware Address of selected MCP23008 Device
I2CRegister=9 ' Device Register Address being written to
There is no Hardware initialisation required on the PIC side (other than defining your SCL and SDA pins), but yes, you DO have to initialise your MCP23008's before you use them!
Here is a typical initialisation sequence at initial Power-On for TWO MCP's being configured for OUTPUT (with different inital ON states)...
Refer to the MCP's Datasheet for configuring for your own requirements.Code:For CounterA=0 to 1 If CounterA=1 then I2CAddress=GPA else I2CAddress=GPB endif For I2CRegister=0 to 9 I2CData=0 If I2CRegister=9 then If CounterA=0 then I2CData=%11111111 else I2CData=%00001100 endif endif I2CWrite SDA,SCL,I2CAddress,I2CRegister,[I2CData] Next I2CRegister Next CounterA
Hi Melanie,
In fact this is only a matter of definition of the addresses in a specific context.
If one consider the MCP23008 "as it", its address is determined by A2, A1, A0 and the higher bits which are predetermined for this specific component. At this level of the design nobody knows in which context (program, compiler, hardware) the component is going to be used and the address has to be written as : 20H + (A2,A1,A0). For example, if (A2,A1,A0) = (0,0,1) then the address is 21H. We can call it a physical address and it is only component dependant.
Now, if we want to pass this address to a PBP program, we have to shift it once left to leave some room for the R/W bit. Therefore this specific byte field value will be obtained by multiplying the physical component address by two (shift left once) and leaving the R/W to 0. At this level and for the hereabove example the field value is equal to 42H.
Formally speaking, it is not very logical to pass an already shifted physical address to the program but once this is known and clear, no problem, it works.
Best regards
MikeBZH / F8DFN
Bookmarks