Jump to content

Recommended Posts

Posted

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

Posted

For J10:SO you would do:

PORTCbits.RC5 = 0;

or

PORTCbits.RC5 = 1;

J10:RC is PORTCbits.RC4.

Simple enough, eh?

Posted

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.

Posted

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!

Posted

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!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...