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 CCS Technical Support

How can we change pin assignments ?

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



Joined: 17 Oct 2006
Posts: 8

View user's profile Send private message

How can we change pin assignments ?
PostPosted: Wed Nov 01, 2006 3:35 am     Reply with quote

Dear friends,

How can we change pin assignments for same process routines
at runtime ?

Not for DS1820 specific problem, just an example:

Code:

        ResetDS1820_Indoor();
        cDataOut = DS1820_SKIP_ROM;
        WriteDS1820_Indoor();
        cDataOut = DS1820_CONVERT_T;
        WriteDS1820_Indoor();
        WaitForConversion_Indoor();
        ResetDS1820_Indoor();
        cDataOut = DS1820_SKIP_ROM;
        WriteDS1820_Indoor();
        cDataOut = DS1820_READ_SCRATCHPAD;
        WriteDS1820_Indoor();
        ReadDS1820_Indoor();
        iTemperature = iDataIn / 2;  // INDOOR Temperature
       // LCD or 7Seg Call routines here

        ResetDS1820_Outdoor();
        cDataOut = DS1820_SKIP_ROM;
        WriteDS1820_Outdoor();
        cDataOut = DS1820_CONVERT_T;
        WriteDS1820_Outdoor();
        WaitForConversion_Indoor();
        ResetDS1820_Outdoor();
        cDataOut = DS1820_SKIP_ROM;
        WriteDS1820_Outdoor();
        cDataOut = DS1820_READ_SCRATCHPAD;
        WriteDS1820_Outdoor();
        ReadDS1820_Outdoor();
        iTemperature = iDataIn / 2;  // OUTDOOR Temperature
       // LCD or 7Seg Call routines here


I use same routine twice for one work:
....._Indoor() and ....._Outdoor() are same but pins different.

Is this possible: Read_DS ( PortPin )
Is there any method for this ?

Thank you.
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 7:53 am     Reply with quote

Greetings,

I do not like using global flags, but if you know which function you are calling, set a flag and use the flag to signal what inputs you want to measure. Check the flag inside your routine for which pins to measure (maintains your calling routine).

something like

if (m_bFlag)
{
data = read_adc(my_pin1);
}
else
{
data = read_adc(my_pin2);
}

I'm not sure I understand your problem. Do you have one 'read' function or two? If two you do not have a problem, just use the pin internal to that function. If not, the 'flag' idea might be acceptable. Or make two read functions and call the appropriate one Read_ds_indoor(), Read_ds_outdoor(); Or create a function which scans all your pins continusously one each iteration of your main().

Cheers,
JMA
LazBoy



Joined: 17 Oct 2006
Posts: 8

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 2:13 am     Reply with quote

Thanks for reply jma_1,

#define LED PIN_A2

As a summary:
Can we change this definition at runtime ? Possible ?
Or there are any methodes for this ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 2:42 am     Reply with quote

Quote:
Can we change this definition at runtime ? Possible ?
Or there are any methodes for this ?

This may be what you want:
http://www.ccsinfo.com/forum/viewtopic.php?t=27923&start=2
LazBoy



Joined: 17 Oct 2006
Posts: 8

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 5:20 am     Reply with quote

Thank you.
C Turner



Joined: 10 Nov 2003
Posts: 40
Location: Utah

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 6:56 pm     Reply with quote

The best way to do this would be to use the same pin for both temperature sensors - but this does, admittedly, complicate things very slightly.

First, you would connect just the "outdoor" sensor, then read its serial number from ROM (using the "READ ROM" command) and then store it in the PIC's EEPROM.

You would then disconnect the "outdoor" sensor and connect the "indoor" sensor only, read its serial number from ROM and then store that in the PIC's EEPROM.

In doing this, you'd have the serial number from both devices and would then be able to put both on the same I/O line and address them independantly using the MATCH ROM command and this would require only one line.

Of course, if you use parasite power, you'd be able to only do one conversion at a time as you'd have to wait for one to complete and then read it before stating conversion on the the other unit.

Alternatively, one could use the "serial number discovery" process to have the PIC determine what the serial number of each unit was on its own - but you'd still have to figure out a way to tell it which was the indoor and which was the outdoor.

CT
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