have implemented algorithm correctly:
void dostartdisplay()
{
uint32_t luntimeelapsed = micros(), lunperiod = 0, lunmask = 0;
lunperiod = luntimeelapsed - lintlasttimeelasped;
lunmask = lunperiod >> 31;
lunperiod = (lunmask ^ lunperiod) - lunmask;
lintlasttimeelasped = luntimeelapsed;
luntimeslice = lunperiod / (60 * 6);
luncount = 0;
// timer1.attachinterrupt(dodisplay, luntimeslice);
// dodisplay();
}
i trying rid of if statement had consume more cpu cycles.
void dostartdisplay()
{
uint32_t luntimeelapsed = micros(), lunperiod = 0, lunmask = 0;
lunperiod = luntimeelapsed - lintlasttimeelasped;
lunmask = lunperiod >> 31;
lunperiod = (lunmask ^ lunperiod) - lunmask;
lintlasttimeelasped = luntimeelapsed;
luntimeslice = lunperiod / (60 * 6);
luncount = 0;
// timer1.attachinterrupt(dodisplay, luntimeslice);
// dodisplay();
}
i trying rid of if statement had consume more cpu cycles.
why not reduce isr to
and rest of calculation outside isr
your names not chosen relate to.
...r
code: [select]
void dostartdisplay() {
luntimeelapsed = micros();
}
and rest of calculation outside isr
your names not chosen relate to.
...r
Arduino Forum > Using Arduino > Programming Questions > Dealing with micros rollover in an ISR
arduino
Comments
Post a Comment