I'm working on interfacing to a GPS, and capturing the "1 pulse per second" signal that it outputs. Today I got things wired up and running, but I'm not having any luck with input capture. Partial code:
timer_init() is called on startup, and there's an ISR(TIMER4_COMPA_vect) that does some timekeeping code that I didn't include -- it works just fine. I'm also running a mainloop that copies data from the GPS serial port (Serial1, pins 18/19) to the USB, which is also working alright.
The PPS line is normally 0V, but goes to 3V for a 1-microsecond pulse. If I wire it to pin 2, I can get the INT4 interrupt to fire, but if I wire it to pin 48 I get nothing. I was thinking that maybe the level or duration was too small for the input capture pin, so I also tried momentarily shorting pin 48 to the 3V3 and 5V lines, and still not a peep out of the interrupt handler, which leads me back to software. Do I have any obvious bugs?
That's certainly a good call -- unfortunately it's not doing anything on pin 49 either. I'm getting good results using pin 2, and I've started writing my PLL using that -- but I'd still like to get input capture working and not worry about how many microseconds I'm losing on the way into the ISR
After several days of ditching the problem and working on other parts of the code, I finally found out what was wrong with input capture, and I hate to say it, but it was a typo. Documenting it here in case anyone else ever has a similar problem and needs to google it.
If you define ISR(TIMER4_CAPT_vect), it gets macro-expanded into a function __vector_8 with flags that convince the linker to install it into the interrupt table. But if you define ISR(TIMER4_CAPT_vec), without the t it turns into a function ISR_CAPT_vec which silently does absolutely nothing.