View previous topic :: View next topic |
Author |
Message |
qtthuan
Joined: 06 Jul 2011 Posts: 4 Location: Canada
|
can I switch btw i2c and i/o config as 2 wire communication? |
Posted: Wed Jul 06, 2011 2:46 pm |
|
|
Hi all,
I'm new to this program stuff and current using pickit3 with the pic12lf1822. I have a temperature sensor (i2c) and humidity sensor (2wire communication that is not compatible with i2c). I got the I2C working ok but when I try to use the scl and sda as general i/o to produce 2 wire communication it does not work. Can I switch between the i2c and general i/o for the 2 wire communication? If so how do i do that? Thank you.
Best Regards,
Tony. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 06, 2011 7:09 pm |
|
|
I guess this means you are using the hardware i2c module (MSSP) and
you want to disable it, and use those pins for general purpose i/o.
This line should do it:
|
|
|
qtthuan
Joined: 06 Jul 2011 Posts: 4 Location: Canada
|
|
Posted: Thu Jul 07, 2011 11:27 am |
|
|
Yes that's it. One more question. Do you have any example code to generate clk and data using the general purpose i/o for the 2 wire communication? Its similar to i2c format but the start condition is different. I took care of the start condition. I don't know how to generate the 9 clk with 8 bit data and ack bit at 100khz for read and write.
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 07, 2011 11:49 am |
|
|
Post the manufacturer and part number of the humidity sensor. There
may already be a driver posted on the forum. |
|
|
qtthuan
Joined: 06 Jul 2011 Posts: 4 Location: Canada
|
|
Posted: Thu Jul 07, 2011 12:59 pm |
|
|
manufacturer: Sensirion
MFG PN: SHT71 |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Thu Jul 07, 2011 1:17 pm |
|
|
There is a driver for the SHT75 in the Code Library which should be the same... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
qtthuan
Joined: 06 Jul 2011 Posts: 4 Location: Canada
|
|
Posted: Thu Jul 07, 2011 2:39 pm |
|
|
Found it. thank you. |
|
|
|