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

all ways to change pin output

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



Joined: 24 Jan 2015
Posts: 63

View user's profile Send private message

all ways to change pin output
PostPosted: Sun Dec 11, 2016 3:30 pm     Reply with quote

Hi there, probably the truth is out there but I cannot find it. A simple question.
Other that output_high(pin) what other way exist to set pins in boolean way?
For example how can I set a pin x high when pin y is low ( both outputs)?
Or to say that if pins x ,y (inputs) are both high,set w high too.
temtronic



Joined: 01 Jul 2010
Posts: 9125
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 11, 2016 3:37 pm     Reply with quote

1) you can read a port and use a 'mask' to set/reset individual pins when you write to that port.

2) you need to read the port, decide if x is high, then set y. similar proceedure to above

3) simple combination logic. Any 'C101' book should explain it

the CCS manual may have examples, the examples folder probably does and of course Google can find anything !

As there are several ways to do all of this, how you do it depends on several factors. PIC type, speed reqd, available memory,etc.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 11, 2016 3:45 pm     Reply with quote

From the CCS manual:
Quote:

output_bit(pin, value)

Outputs the specified value (0 or 1) to the specified I/O pin.


Quote:

output_float(pin)

Sets the specified pin to the input mode. This will allow the
pin to float high to represent a high on an open collector
type of connection.


Quote:
output_drive(pin)

Sets the specified pin to the output mode.
nuclear__



Joined: 24 Jan 2015
Posts: 63

View user's profile Send private message

PostPosted: Sun Dec 11, 2016 4:07 pm     Reply with quote

temtronic wrote:


2) you need to read the port, decide if x is high, then set y. similar proceedure to above
.

Can you give me an example in one statement;

I guess a= input_state(pin_a1);
And then how to use 'a' to set pin_a2?
temtronic



Joined: 01 Jul 2010
Posts: 9125
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 11, 2016 4:20 pm     Reply with quote

output_bit(pin_a2, a);
or maybe

output_bit(pin_a2, input_state(pin_a1));

I can't try. not on compiler computer...

edit...
Code:

33:  output_bit(testled, input_state(testin));
  00E6    B280     BTFSC 0xf80, 0x1, ACCESS
  00E8    D002     BRA 0xee
  00EA    9089     BCF 0xf89, 0, ACCESS
  00EC    D001     BRA 0xf0
  00EE    8089     BSF 0xf89, 0, ACCESS
  00F0    9092     BCF 0xf92, 0, ACCESS

this compiles so it should work....
testled is pin a0, testin is pin a1
PIC is 18F46k22


Jay
nuclear__



Joined: 24 Jan 2015
Posts: 63

View user's profile Send private message

PostPosted: Sun Dec 11, 2016 10:23 pm     Reply with quote

Thank you both guys.
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