 | Discussion Forum |  |
|
|
Question with DALLAS 1-wire bus deviceNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Eric Yeow Posted 30-Dec-2003 22:16 GMT Toolset C51 |  Question with DALLAS 1-wire bus device Eric Yeow Folks ……
I am working with a DALLAS 1-wire bus device and I am begging your help for the following problems:
/* for initializing Device */
void INI ( void) {
CHECK1 = Reset(); if ( CHECK1 == TRUE ) { OS_nop ( 1000 ); /* time delay */ WriteByte(0x1f); }
CHECK2 = Reset(); if ( CHECK2 == TRUE ) { OS_nop ( 1000 ) /* time delay */ WriteByte(0xbe); } }
void WriteByte(unsigned char DAT) {
for(j = 1; j<= 8; j++) {
/* code */
} OS_nop ( 20 ); /* time delay */ }
Why CHECK1 can be returned with TRUE and CHECK2 always get FALSE?
Is there any problem related with WriteByte()?
Thank you and Happy New Year… | | Read-Only Author Andy Neil Posted 1-Jan-2004 22:56 GMT Toolset C51 |  RE: Question with DALLAS 1-wire bus device Andy Neil It is completely impossible to answer you question, as you have omitted to tell us a whole load of fundamental details!
eg, what 1-wire device are you using?
Also, please use the 'pre' and '/pre' tags when posting code - the instructions are right there before your very eyes whenever you make a post to this forum!
"Why CHECK1 can be returned with TRUE and CHECK2 always get FALSE?"
Without knowing what your reset() function does, there is absolutely no way to tell! Also, how have you defined TRUE and FALSE?
Have you tried just using the example code from Dallas? See App Note 126: 1-Wire Communication Through Software. http://www.maxim-ic.com/appnotes.cfm/appnote_number/522/ln/en You can just cut-and-paste the reset, read-bit and write-bit functions and they work - I know. All you need to do is add your delay function.
Even if you can't use this code in your final project, it should at least tell you if your hardware's working!
Have you looked at what's happening on the 1-Wire bus with a 'scope? | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|