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

How to define a struct including multi pin

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



Joined: 07 Apr 2011
Posts: 2

View user's profile Send private message

How to define a struct including multi pin
PostPosted: Thu Apr 07, 2011 9:48 am     Reply with quote

I want to control multi GPIO , say multi pins in different port, the application is to drive a stepper motor, the driver pins are in different port, instead of doing output_high(PIN_x), is there a way to control all these pins at one time ?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 07, 2011 10:04 am     Reply with quote

See the set_spare_bits() macro in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=18949
leeqm



Joined: 07 Apr 2011
Posts: 2

View user's profile Send private message

PostPosted: Fri Apr 08, 2011 10:22 am     Reply with quote

I test with the 4 bit of different port, it works fine, Thanks

However I was wondering can I do it in the "struct" way ?

I searched about the Microchip C18 about the same question got like:

# How can I remap a group of pins on different ports into a single structure?

You can't. C places all of the members of a structure in address order. C does not support the concept of writing to scattered memory addresses in a single operation.

There is no simple or clean mechanism to logically rearrange port pins. The most straightforward technique is to write a function that encapsulates the necessary operations on the port pins. See the following three questions for further discussion.


Is this the same answer for CCS C compiler ?
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