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 support@ccsinfo.com

ds1820_read problem

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



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

ds1820_read problem
PostPosted: Sat Mar 09, 2013 2:43 pm     Reply with quote

Hello!
I try code from first reply:
http://www.ccsinfo.com/forum/viewtopic.php?t=28425
It compiles successfully.
But it’s a strange problem with ds1820_read() function.
Code:
lcd_putc("\f1234");// print
delay_ms(400);
temperature = ds1820_read();
lcd_putc("\f5678");// NEVER print
delay_ms(400);

LCD prints 1234, but 5678 – never print.
ds1820_read() function like stop the program.

P.S.
I found this infinite loop.
Code:
while (busy == 0)
  busy = onewire_read();

This function
Code:
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 );
}

I don't know why always return the wrong value.
Ttelmah



Joined: 11 Mar 2010
Posts: 19353

View user's profile Send private message

PostPosted: Sun Mar 10, 2013 5:24 am     Reply with quote

It's not seeing the device. It waits for the device to return some data. It's seeing 'ONE_WIRE_PIN' as permanently low.
Have you got the pin definition right to match your device?.
The code further down the thread is slightly 'improved' (gives the full resolution), but this should work OK, if the hardware is OK.

Best Wishes
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