|
|
View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Aug 24, 2012 2:03 am |
|
|
As has already been said by PCM programmer. The key thing is that if he uses a software I2C, no translation at all is needed. No diodes. No MOSFET's, etc. etc...
I2C, is already an open collector drive, with the bus only being driven low, or allowed to float.
All that is needed is:
Code: |
+3v
|
/
\ (2K2 - 4K7, is too high for reliable 3v I2C)
/
|
PIC pin------o------ I2C device
|
On both the lines.
It really is this simple.
The pull up resistor allowed, for normal I2C, with 3v pullups, is 866R minimum, 3.2Kmax to meet fast mode timing requirements (unless the bus has very low capacitance <30pF)
Remember as I already mentioned that the resistor needed has to reduce with the supply voltage. 4K7, actually goes outside the recommended resistor range when using 3v pull ups.
Best Wishes |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Fri Aug 24, 2012 6:15 am |
|
|
The MSSP is also open collector (actually open drain) in hardware i2c master mode-- fig 9.16 on the 16f87xa datasheet. I'm a bit confused about why people keep saying that it's open collector only in software mode. Is it because of the slave configuration? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Aug 24, 2012 7:15 am |
|
|
No, the reason that only software will work, is the input, not the output.
The hardware MSSP (I2C) module has a Vih, of 0.8* the PIC's Vdd. So with a 5v PIC, 4v. So if it is being being driven off an I2C device with the pull-ups going to 3v, it'll never see a 'high', and won't work....
This is the point about choosing pins with TTL input buffers, where Vih is low enough to happily work off the 3v device.
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Aug 24, 2012 9:47 am |
|
|
Ttelmah wrote: | No, the reason that only software will work, is the input, not the output.
The hardware MSSP (I2C) module has a Vih, of 0.8* the PIC's Vdd. So with a 5v PIC, 4v. So if it is being being driven off an I2C device with the pull-ups going to 3v, it'll never see a 'high', and won't work....
This is the point about choosing pins with TTL input buffers, where Vih is low enough to happily work off the 3v device. |
That's a good point.. I work with the lower voltage devices so regularly now...
Ahhh, mixing I2C bus voltages... something I make it a point to avoid. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Aug 24, 2012 9:49 am |
|
|
Mahdi wrote: |
I'm using 16f877a.
|
I'm curious.
Are you doing this for for class or for work or for personal fun?
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Fri Aug 24, 2012 11:05 am |
|
|
Ttelmah wrote: | No, the reason that only software will work, is the input, not the output.
The hardware MSSP (I2C) module has a Vih, of 0.8* the PIC's Vdd. So with a 5v PIC, 4v. So if it is being being driven off an I2C device with the pull-ups going to 3v, it'll never see a 'high', and won't work....
This is the point about choosing pins with TTL input buffers, where Vih is low enough to happily work off the 3v device.
Best Wishes |
Thanks! I'm in a design now where I'm pulled up to 3V using hardware i2c, and everything seems to be working. I'm on an 18f, and in i2c mode Vih is 0.7 Vdd, so it shouldn't and does, but I'll assume it won't do so reliably! The plan is to isolate this part of the 12c bus anyway, so I'll just have the microcontroller bus pulled to 5v anyway, but it's nice to know! |
|
|
Mahdi
Joined: 21 Aug 2012 Posts: 47
|
|
Posted: Fri Aug 24, 2012 1:54 pm |
|
|
bkamen wrote: | Mahdi wrote: |
I'm using 16f877a.
|
I'm curious.
Are you doing this for for class or for work or for personal fun?
-Ben |
for a project |
|
|
Mahdi
Joined: 21 Aug 2012 Posts: 47
|
|
Posted: Fri Aug 24, 2012 1:57 pm |
|
|
sseidman wrote: | Ttelmah wrote: | No, the reason that only software will work, is the input, not the output.
The hardware MSSP (I2C) module has a Vih, of 0.8* the PIC's Vdd. So with a 5v PIC, 4v. So if it is being being driven off an I2C device with the pull-ups going to 3v, it'll never see a 'high', and won't work....
This is the point about choosing pins with TTL input buffers, where Vih is low enough to happily work off the 3v device.
Best Wishes |
Thanks! I'm in a design now where I'm pulled up to 3V using hardware i2c, and everything seems to be working. I'm on an 18f, and in i2c mode Vih is 0.7 Vdd, so it shouldn't and does, but I'll assume it won't do so reliably! The plan is to isolate this part of the 12c bus anyway, so I'll just have the microcontroller bus pulled to 5v anyway, but it's nice to know! |
my 16f877 i2c with 3 volt work but unstable |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Aug 24, 2012 2:02 pm |
|
|
Mahdi wrote: | for a project |
And that would be a project for school? Work? Personal Fun? _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Mahdi
Joined: 21 Aug 2012 Posts: 47
|
|
Posted: Sat Aug 25, 2012 12:22 am |
|
|
bkamen wrote: | Mahdi wrote: | for a project |
And that would be a project for school? Work? Personal Fun? |
For work. It is used in making the Flush or Protractor. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sat Aug 25, 2012 4:41 am |
|
|
sseidman wrote: | Ttelmah wrote: | No, the reason that only software will work, is the input, not the output.
The hardware MSSP (I2C) module has a Vih, of 0.8* the PIC's Vdd. So with a 5v PIC, 4v. So if it is being being driven off an I2C device with the pull-ups going to 3v, it'll never see a 'high', and won't work....
This is the point about choosing pins with TTL input buffers, where Vih is low enough to happily work off the 3v device.
Best Wishes |
Thanks! I'm in a design now where I'm pulled up to 3V using hardware i2c, and everything seems to be working. I'm on an 18f, and in i2c mode Vih is 0.7 Vdd, so it shouldn't and does, but I'll assume it won't do so reliably! The plan is to isolate this part of the 12c bus anyway, so I'll just have the microcontroller bus pulled to 5v anyway, but it's nice to know! |
Which particular PIC?.
Most 18F chips still have Vih for the Schmitt buffers at 0.8*Vdd. However some have the data input buffer on the pins used by the hardware I2C, using TTL buffers, and only the hardware module using Schmitt levels. I'd guess you are actually using _software_ I2C, and don't realise it!. A quick look at the assembler generated will tell you. Remember the internal library defaults to using software, and 'FORCE_HW' is needed to use the hardware. This differs from #use RS232, where if you use the hardware pins, it defaults to using the hardware.....
If you look (for instance), at the 18F4550, on this the I2C pins are RB0/RB1, and the input buffers on these pins are TTL, but the input buffers when using the hardware I2C, are Schmitt. Then in the DC Characteristic table, Vih, for pins with Schmitt buffers is given at 0.8*Vdd, only pins RC3, and 4, have 0.7*Vdd thresholds.
On the chip being used here (16F877A), the I2C is on pins RC3/RC4, and these have Schmitt input buffers when used as normal I/O. However these pis have the 0.7*Vdd threshold, making the voltage nominally 3.5v, which with a 3.3v supply to the second IC, is 'right on the borderline'......
Best Wishes |
|
|
Mahdi
Joined: 21 Aug 2012 Posts: 47
|
|
Posted: Sun Aug 26, 2012 7:56 am |
|
|
i want to write in CLKSEL[2:0] in PWR_MGMT_1 register.what is the address of clksel register? how to write data in clksel?What is the hexadecimal address clksel register? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sun Aug 26, 2012 11:43 am |
|
|
CLKSEL, is not a register. It is bits 2:0 of the PWR_MGMT_1 register.
Looks like address 107, from what you post,but we can never tell without knowing the PIC....
Best Wishes |
|
|
Mahdi
Joined: 21 Aug 2012 Posts: 47
|
|
Posted: Sun Aug 26, 2012 12:45 pm |
|
|
Ttelmah wrote: | CLKSEL, is not a register. It is bits 2:0 of the PWR_MGMT_1 register.
Looks like address 107, from what you post,but we can never tell without knowing the PIC....
Best Wishes |
in the first post i said pic16f877a
thanks alot |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sun Aug 26, 2012 2:42 pm |
|
|
The 877a, doesn't have any CLKSEL bits. These are only present on chips with run time oscillator switching. It doesn't have a power management register either, this only exists on chips supporting different sleep levels. You seem to have pulled the data from a completely different chip, hence my question.....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|