CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

can I switch btw i2c and i/o config as 2 wire communication?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
qtthuan



Joined: 06 Jul 2011
Posts: 4
Location: Canada

View user's profile Send private message

can I switch btw i2c and i/o config as 2 wire communication?
PostPosted: Wed Jul 06, 2011 2:46 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jul 06, 2011 7:09 pm     Reply with quote

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:
Code:

setup_spi(FALSE);
qtthuan



Joined: 06 Jul 2011
Posts: 4
Location: Canada

View user's profile Send private message

PostPosted: Thu Jul 07, 2011 11:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 07, 2011 11:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 07, 2011 12:59 pm     Reply with quote

manufacturer: Sensirion
MFG PN: SHT71
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Jul 07, 2011 1:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 07, 2011 2:39 pm     Reply with quote

Found it. thank you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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