Page 1 of 1

C code

Posted: Mon Dec 29, 2014 10:42 pm
by alanwms
Can I get an example of code to be pasted into the C code icon for FC5 that shows a simple example to:

Look at an input
Turn on an output.


Thanks

Re: C code

Posted: Mon Jan 05, 2015 5:11 pm
by Benj
Hello,

Lets say you have a flowcode variable named test.
Look at an input

Code: Select all

trisb = 0xFF;  // convert RB0-RB7 to Input
FCV_TEST = portb;   // read the value being input to portb pins
Turn on an output.

Code: Select all

trisb = 0x00;   // convert RB0-RB7 to output
portb = FCV_TEST;   // assign value in test variable to portb pins
Some chips have a LAT register as well as a port register, in which case the output code becomes.

Code: Select all

trisb = 0x00;   // convert RB0-RB7 to output
latb = FCV_TEST;   // assign value in test variable to portb pins