i need to get fast response,
as we see while ( ! pin + mask ) wait to signal, set HIGH two pins.
i want to get faster response from
// A Signal
while ( ! (PIND & B00000100) );
PORTD = B00110000;
is there faster way to do it ? ( its ignition controller, so on high rpm each 50 micros is 1.8/360 ...
unsigned long st = 0;
int rpm = 3950;
unsigned int table[] = {
3950, 3945, 3940, 3935, 3930, 3925, 3920, 3915, 3910, 3905,
3895, 3885, 3875, 3865, 3855, 3845, 3835, 3825, 3815, 3805,
3790, 3775, 3760, 3745, 3730, 3715, 3700, 3685, 3670, 3655,
3635, 3615, 3595, 3575, 3555, 3535, 3515, 3495, 3475, 3455,
3425, 3395, 3365, 3335, 3305, 3275, 3245, 3215, 3185, 3155,
3110, 3065, 3020, 2975, 2930, 2880, 2830, 2780, 2730, 2680,
2630, 2580, 2530, 2480, 2430
};
void setup () {
DDRD = B11110010;
PORTD = B00000000;
// Static ignition time
int i;
for (i = 750; i >= 0; i--) {
while ( ! (PIND & B00000100) );
PORTD = B00110000;
delayMicroseconds( 4100 );
PORTD = B00000000;
// B Signal
while ( ! ( PIND & B00001000) );
PORTD = B11000000;
delayMicroseconds( 4100 );
PORTD = B00000000;
}
digitalWrite(13, HIGH);
}
void loop () {
// Float ignition time
for ( ; ; ) {
// A Signal
while ( ! (PIND & B00000100) );
PORTD = B00110000;
st = micros();
delayMicroseconds( rpm );
PORTD = B00000000;
// B Signal
while ( ! ( PIND & B00001000) );
PORTD = B11000000;
delayMicroseconds( rpm );
PORTD = B00000000;
rpm = table[ int ( 300000 / float ( micros() - st ) ) ];
}
}
