View previous topic :: View next topic |
Author |
Message |
Graham Bremner Guest
|
Problems when changing from O/P to I/P |
Posted: Wed Mar 05, 2003 6:47 am |
|
|
Hello,
I am trying to link a pic16F877 to a sensirion SHT11 humidity sensor. I am basing my code on the sample code for an 80c51 processor.
It is a 1 wire interface, used for both reading and writing.
Initially I set it up using.
set_tris_b(0x01);
#USE FAST_IO(B)
next I send a data sequence to the device on RB2, then
set_tris_b(0x05); //RB2 as I/P, already given the name data
#USE FAST_IO(B)
while (DATA==1) {
delay_ms(1); }
This should loop until data has gone low but it exists this
loop straight away, when data is still high.
I dont think it is a timing problem as data is high for 5ms before the loop is called.
Any ideas??
Thanks
G Bremner
___________________________
This message was ported from CCS's old forum
Original Post ID: 12369 |
|
|
Hans Wedemeyer Guest
|
Re: Problems when changing from O/P to I/P |
Posted: Wed Mar 05, 2003 11:23 am |
|
|
:=while (DATA==1) {
What code are you using for DATA ?
Is it a #define or what ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12381 |
|
|
Graham Bremner Guest
|
Re: Problems when changing from O/P to I/P |
Posted: Thu Mar 06, 2003 4:55 am |
|
|
Hi,
Yes, I am just using #define.
I have got round the problem by using 2 pins. One for o/p and 1 for I/P. This now gives me a 2 wire connection to the pic and its works fine. Using an extra line but I had 2 spare anyway.
Thanks for your intrest
___________________________
This message was ported from CCS's old forum
Original Post ID: 12419 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Problems when changing from O/P to I/P |
Posted: Thu Mar 06, 2003 1:59 pm |
|
|
:=Hi,
:=
:=Yes, I am just using #define.
:=
:=I have got round the problem by using 2 pins. One for o/p and 1 for I/P. This now gives me a 2 wire connection to the pic and its works fine. Using an extra line but I had 2 spare anyway.
:=
--------------------------------------------
I once posted some notes on how to convert their sample driver
for the SHT11 (written for the Keil compiler) to CCS.
<a href="http://www.pic-c.com/forum/general/posts/3989.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/3989.html</a>
Here's their sample driver:
<a href="http://www.sensirion.com/en/pdf/ApplNote_SHTxx_c1.pdf" TARGET="_blank">http://www.sensirion.com/en/pdf/ApplNote_SHTxx_c1.pdf</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12442 |
|
|
|