baptistou Posted September 30, 2009 Report Posted September 30, 2009 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 Quote
nILS Posted September 30, 2009 Report Posted September 30, 2009 For J10:SO you would do:PORTCbits.RC5 = 0;orPORTCbits.RC5 = 1;J10:RC is PORTCbits.RC4.Simple enough, eh? Quote
baptistou Posted October 1, 2009 Author Report Posted October 1, 2009 And can you read these ports so easily as well? Quote
nILS Posted October 1, 2009 Report Posted October 1, 2009 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. Quote
baptistou Posted October 3, 2009 Author Report Posted October 3, 2009 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! Quote
nILS Posted October 3, 2009 Report Posted October 3, 2009 Get yourself a copy of the datasheet and look for info on the TRIS* registers :-) Quote
baptistou Posted October 5, 2009 Author Report Posted October 5, 2009 It looks like I only have to put something likeTRISCbits.TRISC5 = 0 or 1I'll try that as soon as I have the time, thanks for the help! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.