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

DS2480 and ds2408 help appreciated

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



Joined: 05 Apr 2006
Posts: 23

View user's profile Send private message

DS2480 and ds2408 help appreciated
PostPosted: Fri May 25, 2007 12:13 pm     Reply with quote

I have read data sheets. I have searched and read all pertinent posts for 1-wire. I sort of have a grasp on things but I am finally putting my pride aside and am asking for help. I am attempting a simple circuit, uC -> ds2480 -> ds2408.
I have found/modified this code as a starting point:
Code:
short int onewire_init_with_error_check()
{
// master_reset(); //
int reset, present;
putc(0xC1); //Send a reset in command mode
reset = getc(); //Read the response byte
if((reset != 0xCD) || (reset != 0xED)) //If not right response
present = 3;
else
present = 4;

return present;
}

This always returns 3. (Using ICD watch variables, I changed the code to return a non-zero value.) I am currious why the code reads the response byte. Should there not be two bytes? The code tests for CD or ED, those are two characters, ie two bytes, right?

I have my uC uart pins connected to the ds2480. It is unclear to me looking at the data sheet if this should be a NULL connection or not. Does uC Tx connect to ds2480 Tx or Rx? I have tried both configurations and no luck so far. ( I am assuming my rs232 is working correctly. Not tested yet. No rs232 converter to talk to a PC terminal program.)
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri May 25, 2007 4:00 pm     Reply with quote

According to the function declaration, it is expected to return a SHORT, instead you are trying
to return an INT.
In CCS, a SHORT is 1 bit wide number, is a special type used to generate very efficient code for
bit operations and I/O.
While an INT is an 8 bit number.

Quote:

It is unclear to me looking at the data sheet if this should be a NULL connection or not.
Does uC Tx connect to ds2480 Tx or Rx?

I guess you misunderstood the meaning of One-Wire.
The terms Tx, Rx and NULL are used widely in RS232 serial communication, they don´t
have any meaning in One-Wire communication protocol.

Search in Maxim/Dallas Semiconductor site for primary source info regarding this
propietary protocol.

http://pdfserv.maxim-ic.com/en/an/app162.pdf


Humberto
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Tue May 29, 2007 4:44 am     Reply with quote

Hello jimcbride,

You have to connect the TX to TX and RX to RX. It is very special that the RX of the DS2480 is in fact is TX and same to TX.

Take care about the DS2480 support 5v level rs/232. Then you cannot connect it directly to your PC rs/232.

As humberto say, correct your code by:

Code:

short int onewire_init_with_error_check()
{
 int reset, present;
  // master_reset(); //
  putc(0xC1);                              //Send a reset in command mode
  reset = getc();                          //Read the response byte
  if ((reset == 0xCD) || (reset == 0xED))  //If right response
    present = true;
  else
    present = false;

  return present;
}


Humberto,
The DS2480 is a 1-wire controlleur, with 1-wire by one side and rs/232 by the other side.


Best regards,
dro
_________________
in médio virtus
jimcbride



Joined: 05 Apr 2006
Posts: 23

View user's profile Send private message

PostPosted: Tue May 29, 2007 9:29 am     Reply with quote

Thank you both for your respnse. Yes the code was a little messed up by me playing around trying to look at variables during code execution. I was trying to make sure where the TRUE/FALSE was comming from and more importantly, is the communication between the Pic and the DS2480 working correctly? Since I am always returning a false, I have to assume that I am not talking to the DS2480.
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Tue May 29, 2007 11:03 am     Reply with quote

Hello,

Did you connected a 1-wire device to the DS2480 ?

dro.
_________________
in médio virtus
jimcbride



Joined: 05 Apr 2006
Posts: 23

View user's profile Send private message

PostPosted: Wed May 30, 2007 9:45 am     Reply with quote

Yes I have a DS2408.
I think I have my clock issues figured out.
Now I think I have a new problem. Do I need a reset pulse with the DS2480? I know the one wire has a reset pulse but won't the DS2480 be different?

When I send a 0xC1 to the DS2480, I believe it is sending me back a 0xB0. The code will run once through and then wait forever to recieve additional bytes. Makes sense I guess but why am I getting back a 0xB0? I see nothing in the daasheet about that code. I get the same response with or without the DS2408 connected.

edit.. B0 was an anomally. For some reason it would show up AFTER a getc() call. It still showed up when the Tx/Rx lines were removed. Not sure how or why that was happening. After messing around and watching communications with a scope I have determined that I am running very close to 9600 baud. I am sending a valid reset command (0xC1). The DS2480 is not responding in any way. Checked all connections. Try new part?
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