Re: Interrupt Problems
I didn't make all the work for you.
Some parts are to fill up with your own code, because I don't know your requirements.
1. The function void init_v(void) is to fill up with code to initialize your controller.
- clock
- ports
- uart
- interrupts
- timer with 100µs!
etc.
It depends from type of controller Microchip, Atmel, Renesas, what ever....
2. The function void unsigned char angle2time_u8(unsigned char angle_u8) is to fill up with code to calculate high time of your servo pwm.
http://www.ermicro.com/blog/?p=771 means
0.7ms to 1ms PWM high time turns CW
1.7ms to 2ms PWM high time turns CCW
1.5ms PWM high time turns to center
So you need a transfer function to calculate high time because
high time = f(servo angle)
for 90°=center =>
0-180° => 0.7-2ms => 7-20
0 <= angle_u8 <= 180
7 <= angle2time() <= 20
3.
while(1)
{
// get your angle and set ServoXAngle_u8
}
I guess you want change servo angle at runtime. Anyhow you has to transmit the new servo angle to your controller (UART, SPI, DIP-Switches, ADC what ever). In this while you take the new angles and set ServoXAngle_u8 (X=1|2|3). You has to add some own code to read in new angle values.
Gomez