Hi all,
It is known that millis() (that is interrupt driven) can not update time when run within an interrupt handler function.
I tried to detach the interrupt within the handler, after its start, and read the millis(), but the millis does not update although the interrupt was detached.
I have also tried to have an in-between handler to run my function, but it is still the same: The millis() timer does not advance.
(Does this mean that whenever there is an active interrupt, the timer freezes?!)
I still wish I could start the function by an external interrupt!
Is this normal and is there a reasonable workaround to that?
The code looks like: (simplified)
void setup()
{
attachinterrupt(enableChannel, run_cycle, RISING);
}
void run_cycle()
{
detachInterrupt(enableChannel);
uint16 count = 0;
uint32 starttime = millis();
do
{
uint8 nowstate = digitalRead(runChannel);
while (digitalRead(runChannel)== nowstate) { } //Loop until logic change
uint16 time = (millis() - starttime) & 0xFFFF;
count ++;
}
while (digitalRead(enableChannel) == 1);
attachInterrupt(enableChannel, run_cycle, RISING);
Select_Mode(time, count);
}