Question about Hz and programming

Status
Not open for further replies.
So I finally found a place I can mooch some internet connection till tomorrow when they get our internet set up. So I got out of class today and worked on some code, it's really simple but I'm still not sure I've got all the registers set up right but I figured I'd post it and see if it's right or not. All the code is supposed to do is turn a servo to 90 degrees. If I had the code right I was going to edit it to do more stuff but like I said I'm not sure I got the registers set up right. I'm hopefully going to get to order some servos sometime in the next few weeks and then I'll get to actually test some of my code and see if it works. I appreciate all the help guys.

Code:
int servopos;
Int main(){
OSCCON = 0b00001010;
INTCON = 0b11000000;
PIE = 0b00000110;
T1CON = 0b10010001;
CCP1CON = 0b00001011;
TRISA = 0b00000000;
PORTA = 0b00000000;
servopos = 1500;
CCPR1 = servopos;
while (1){
while (!PIR1.CCP1IF){
PORTA.F0 = 0;
CCPR1 = 20000 - servopos;
PIR1.CCP1IF = 0;
while (!PIR1.CCP1IF){
PORTA.F0 = 1;
CCPR1 = servopos;
PIR1.CCP1IF = 0;
}}
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…