Hi! I am trying for 3 days to control basic servo motor (sg90) by using Pic16f877a by Timer0 in Mplab XC8 compiler.
Pic16f877a servo motor control by Timer0
Code (Text):
- #include <xc.h>
- #include <stdint.h>
- #include "config.h"
- #define _XTAL_FREQ 6000000
- uint16_t counter = 0;
- uint16_t on_time = 281, pwm_period_time = 3750;
- void main(void) {
- TRISD = 0x00;
- PORTD = 0x00;
- PSA = 0;
- TMR0 = 252;
- T0CS = 0;
- //Prescaler
- PS0 = 0;
- PS1 = 0;
- PS2 = 0;
- TMR0IE = 1;
- TMR0IF = 0;
- PEIE = 1;...