I have an odd problem and I'm hoping that by trying to explain it I
can solve it...
What I have is an timer overflow ISR that tics off every 10us. I've
coded it thusly:
// variables at the top (global)
//ISR variables, volatile by nature
volatile uint16_t t_10us=0;
volatile uint32_t t_1ms=0;
volatile uint16_t repeat=0;
volatile uint16_t match=0; // The single servo used
uint8_t servo = 150;
// past initializations and such ...
SIGNAL(SIG_OUTPUT_COMPARE0)
/*
* 10 microsecond ISR
*/
{
t_10us++;
if (t_10us > 100)
{
t_1ms++; //1ms background clock
t_10us = 0;
repeat++;
if (repeat == 19)
{
repeat = 0;
SPIN = 1; //raise servo pin high
match = 0; //start servo timer
}
}
match++; //increment every 1
if (match == servo)
SPIN=0; //drop servo bit
}
Now for the weird part. This all above seems to work fine unless I
update "servo" too often. As seen below:
// More code goes by...
servo = 100;
for (i=100;i<215;i+=2)
{
servo = i;