Hi,
It's almost midnight in Japan, so just a quick note...
Quote:
Originally Posted by dcb
You mean the arduino millis() that overflows after 9 hours. I'm aware of the bug, but didn't hear that they were going to remove timer0_overflow_count.
It is still there in arduino 11, but we can adapt if they do remove it. But I'm impressed at what a quick study you have made of the platform
|
arduino 0011 was release on March 28, and they changed the millis() on April 18.
http://svn.berlios.de/viewcvs/arduin...45&view=markup
timer0_clock_cycles variable is defined instead of timer0_overflow_count.
Quote:
Do you know if some cars do not put out an injector signal porportional to RPM? We were just going to add an injectorpulsesPer2Revolutions variable and do the RPM based on the number of pulses per second, or the microseconds between pulses.
|
No, I don't think so.
I observe the injector pulse width and RPM number are changing individually and no relations between them.
Quote:
Maybe. It depends on the minimum time between events that affect a variable and how big the interrupt handlers are. Also sei and cli are global, might just want to mask the interrupts that share variables while you manipulate them. I will investigate further. I think arduino does it for you for attachInterrupt, which is just our injector signal. Also, I never quite got a handle on what happens if you get an interrupt while in an interrupt, does control return to the first interrupt eventually?
|
I saw "attachInterrupt" source and found it's just initializing interrupt register.
I believe you'll see unstable calc results without setting cli().
Code:
//attach the vss/buttons interrupt
ISR( PCINT1_vect ){
static byte vsspinstate=0;
byte p = PINC;//bypassing digitalRead for interrupt performance
if ((p & vssBit) != (vsspinstate & vssBit)){
tmpTrip.vssPulses++;
currentVSS=elapsedMicroseconds(lastVSS);
lastVSS=microSeconds();
}
vsspinstate = p;
buttonState &= p;
}
Regarding to your code above, I think the "vsspinstate" variable has to be a global.
Regards,
Yoshi