shift_right() function

Status
Not open for further replies.

pavelustinov

Newbie level 3
Joined
Mar 9, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,351
Hello!
Function onewire_read() always return 0, so it will be infinite loop.
Function must read data from 18b20 temperature sensor.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int onewire_read()
{
 int count, data;
 
 for (count=0; count<8; ++count)
 {
  output_low(ONE_WIRE_PIN);
  delay_us( 2 ); // pull 1-wire low to initiate read time-slot.
  output_float(ONE_WIRE_PIN); // now let 1-wire float high,
  delay_us( 8 ); // let device state stabilise,
  shift_right(&data,1,input(ONE_WIRE_PIN)); // and load result.
  delay_us( 120 ); // wait until end of read slot.
 }
 
 return( data );
}


Defined

Code C - [expand]
1
#define ONE_WIRE_PIN PIN_A0


Same problem discuss here
https://www.edaboard.com/threads/5984/
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…