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

multiple dallas readers

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







multiple dallas readers
PostPosted: Tue May 13, 2008 8:10 am     Reply with quote

I have two dallas touch button readers connected to pic16f877A.
Each reader is assigned to one pin.

#define Reader1 pin_b6
#define Reader2 pin_b7

I have two functions to read the dallas button. Both functions are identical, except for one uses Reader1 and the other Reader2.

Is there away that I can make this into one function?
I am wanting to add upto 25 dallas readers onto 25 pins and dont want to have the functions duplicated that many times..

Thanks
Delene
KU5D



Joined: 10 Feb 2008
Posts: 46
Location: Asheville, North Carolina

View user's profile Send private message

PostPosted: Tue May 13, 2008 8:14 am     Reply with quote

Might try labeling the pins and passing that label to the function as an argument...
_________________
Confidence is the feeling you have right before you fully understand the situation...
DeleneMulley
Guest







PostPosted: Tue May 13, 2008 8:23 am     Reply with quote

how would you label the pins? (I thought I had done that by with the #define Reader1 pin_b7)
Then how do you pass that label to a function?

Thanks
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Tue May 13, 2008 9:38 am     Reply with quote

Does it have to be two seperate readers? each device has unique id and you usually have a option to discover devices on the bus with the search rom command if memeory serves me correct.

Make an array of two int16 values then assign them the value found in the device.h file under the pin defines, then in your driver switch between the two array elements.

Regards
delene



Joined: 13 Oct 2003
Posts: 32

View user's profile Send private message Send e-mail

PostPosted: Tue May 13, 2008 9:45 am     Reply with quote

They do have to be separate readers..

Your memory is correct on how they work, but for my app they each need to have a separate reader..
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue May 13, 2008 1:25 pm     Reply with quote

Each dallas device on a separate touchpin and up to 25 of them seems very kludgey but I assume it makes sense to you. You may decide since the hardware is duplicated 25 times that if there is enough program memory why not go for the gold and duplicate your software as well. Now you won't have to duplicate your routines 25 times if you pass a variable with the touchpin number into your routine. Search this board for examples of assigning PIC pins via a variable at run time.
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