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

Fast dynamic pin selection

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



Joined: 24 Feb 2010
Posts: 22

View user's profile Send private message

Fast dynamic pin selection
PostPosted: Mon Apr 12, 2010 8:05 am     Reply with quote

Hi all,

Is there any way to call a function, specifying a certain pin, but doing it fast enough for 1-Wire comms?

As an example, I want to have something like the following:
Code:
int16 my_pin;

void main()
{
    my_pin = PIN_A1;
    do_one_wire_function(my_pin);

    my_pin = PIN_A2;
    do_one_wire_function(my_pin);
}


Is there any way of doing this, without messing up the timing for 1-Wire comms? I realize that it sort of defeats the purpose of 1-Wire comms. I've been struggeling for a week with the SEARCH ROM algorithm and finally got it working today. But, while I was working on it, it struck me that I wouldn't even use it.

I am using the DS18B20 1-Wire temperature sensors. I need to connect a sensor on each of 6 microcontroller pins. This is so that I know exactly which sensor is measuring which temperature (ambient, water, etc.) So you can see why I want to follow this route.

Can anyone please help me with this? I have compiler version 4.106
mskala



Joined: 06 Mar 2007
Posts: 100
Location: Massachusetts, USA

View user's profile Send private message

PostPosted: Mon Apr 12, 2010 8:18 am     Reply with quote

Look at how the sensor works. You can put them all on the same pin, because each one has a unique address.
Swys



Joined: 24 Feb 2010
Posts: 22

View user's profile Send private message

PostPosted: Mon Apr 12, 2010 8:29 am     Reply with quote

Thanks for the reply.

That's correct, but the problem is that I won't know in the field which sensor has what address when I pick one out of a toolbox and put it in the circuit. That is why I want to use a differrent pin for each sensor.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Apr 12, 2010 12:41 pm     Reply with quote

If the pin count is 8 or less, you can use a bit number in all port accesses to select the respective pin. You have to
rewrite the OW low-level I/O routines however. But it's a rather simple programming roblem.
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