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

Pin definition help

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



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

Pin definition help
PostPosted: Mon Dec 01, 2008 2:17 am     Reply with quote

I want to be able to have a code segment that will output_high(Output_(i)) or output_low(output_(i)), were output_(i) is assigned to a certain pin, such as #define output_0 pin_a0, #define output_1 pin_b3 ect. The idea is to have (i) as an int8 that can be manipulated easily between 0 and the number of outputs required and thus minimize my code.

Don’t really know how to do it for the output. For reading inputs it was easy all I did was.

Code:
void ReadInput (void)
{
         set_adc_channel(i)
         delay_us(25);
         ADCValue[i] = read_adc();
}
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Mon Dec 01, 2008 2:29 am     Reply with quote

Make an int16 array with the number of elements equal to the number of outputs you want to switch. then initialize the array with the pin defines. This does require more processing power if I'm not mistaken....
Code:

int16 my_outputs[4] = {pin_a0,pin_c3,pin_b2,pin_e1}

//in your code you will access the outputs like this:

output_high(my_outputs[0]);
output_low(my_outputs[3]);
....
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Mon Dec 01, 2008 2:55 am     Reply with quote

cheers for the fast reply.

what do you mean
Quote:
then initialize the array with the pin defines
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