[chbot] Synco's reentrant chocolate fish

Col colp42 at gmail.com
Sat Jul 23 03:46:27 BST 2011


On 23/07/11 13:09, Volker Kuhlmann wrote:
> On Sat 23 Jul 2011 12:37:42 NZST +1200, Col wrote:
>
>> Also my tutors taught me it was bad practice to put loops in ISR's.
>
> Those loops aren't really looping (compare loop variable and setting
> thereof in loop body). They iterate once 255/256 of times, and twice for
> that 1/256 case (assuming 8bit variables). Clever concise coding.
>
> Volker
>

Granted it should only loop one or twice, but what if the line

while (temp_overflow_count != 
number_of_times_the_timer_has_overflowed_during_pulse);

got interrupted by

ISR(TimerOverflow)

I smell a second race condition ( assuming non blocking interrupts )
Can I win the chocolate fish for saying this whole approach is too 
complicated?


Col.



More information about the Chchrobotics mailing list