use and coding of J10 SO and RC pins

Hi there!

Does anyone can give a C code example on how to use the “free to use” pins like J10 SO and RC?

I’m using X-code and I would like to use these pins to do a PWM signal to control a servo. For a servo it’s not real PWM signal but rather a high state during between 1 millisecond (0%) and 2 milliseconds (100%). As the DIN registers are refreshed only once per millisecond it’s not precise enough for me. I hope that by using a timer and these pins I should be precise enough without having a code too heavy.

Thanks in advance!

Baptistou

For J10:SO you would do:

PORTCbits.RC5 = 0;

or

PORTCbits.RC5 = 1;

J10:RC is PORTCbits.RC4.

Simple enough, eh?

And can you read these ports so easily as well?

if (PORTCbits.RC5) {

  // pin is high do something

} else {

  // pin is low do something else

}

Remember to set the pin directions before using them as in/outputs.

And how do you set the pin direction?

Thank you for your help, these are easy syntax but hard to find when you are a newby like me!

Get yourself a copy of the datasheet and look for info on the TRIS* registers :slight_smile:

It looks like I only have to put something like

TRISCbits.TRISC5 = 0 or 1

I’ll try that as soon as I have the time, thanks for the help!

:slight_smile: