Working on understanding the concept of how to make the chip capture the RPM input signals now via the programming.
This is not easy! One of the hardest things to understand I have ever come across in my life! ARG!
Now you guys know why I was avoiding it.
It's very possible though and I'm learning it now.
This stuff makes me pull my hair out! I dread programming
Here you guys figure this out:
Quote:
#define TIMER1_PRESCALE 64
#define FILTIME 1000
volatile unsigned int rpm;
volatile unsigned int diff,in_timeout;
#define IN_RELOAD 20 //if no pulses for 50ms * 20 = 1second, rpm value is zeroed
//TIMER1 initialize - prescale:64
// WGM: 0) Normal, TOP=0xFFFF
// sense on ICP falling edge
void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCCR1A = 0x00;
TCCR1B = 0x83; //start Timer
}
//
//
// RPM pulses get us here
//
//
ISR(TIMER1_CAPT_vect)
{
static unsigned int cap1,prev;
cap1 = ICR1; //gcc reads the capture regs in the correct order!
diff = cap1 - prev; //calc difference
prev = cap1; //update previous value
in_timeout = IN_RELOAD; //reload input timeout
//
// for input filter. disable further input captures for FILTIME ticks
//
TIFR1 = (1<<OCF1A); //clear any previous OCR1A ints
OCR1A = cap1 + FILTIME;
TIMSK1 |=(1<<OCIE1A); //enable COMPA ints
TIMSK1 &= ~(1<<ICIE1); //disable input capture ints
}
|
No freakin' joke!
I'm a wheelie kinda guy not a bookworm.. but I'm doing my best.