Interrupt not fast enough?

I have a two wire serial connection that does not follow any typical hardware serial protocols. So I am working at the bit level.

I am trying to use an interrupt on the clock line so that on the rising edge of the clock pulse I can read the bit from the data line and shift it in to a byte variable.

My issue is I know for a fact that the clock will pulse 145 times, but the interrupt is only capturing 15 of those pulses.

I'm using the arduinos built in functions for enabling and setting an interrupt on pin 3, and then my interrupt function just prints a line to the Serial port for testing purposes.

The only document I have about this serial protocol is that you can read it with a microcontroller capable of an interrupt response in 2us and repeated every 7us, and from what I gather, the ATMega328 is capable of that.

Any ideas?

PS, I'm new to microcontrollers, but hardly an idiot when it comes to programming or electronics, so lets avoid the sharp-shooting jerk responses aimed to highlight ignorance and lack of knowledge.

Don’t use Serial.print inside an interrupt ? You see it ? Line #45 of your program ?

I didn't attach a program... But I will try it without the serial line. Thanks!

roblesterjr04:
I didn't attach a program... But I will try it without the serial line. Thanks!

We know. Hence the comment :slight_smile:

Read here too

"How long does it take to execute an ISR?"
I had a program where I blasted out 45 bytes of data at 20 KHz rate. I noticed odd timing quirks, where the data would get put of sync with the 20KHz pulse that triggered each burst. Problem turned out to be the micros() interrupt that runs in the background. So you may have to consider other interrupt sources as well.

and then my interrupt function just prints a line to the Serial port for testing purposes.

RTFM

AWOL:
RTFM

The "F*ing Manual" says nothing about not using Serial in the interrupt.

Don't use Serial.print inside an interrupt ?

Problem solved. Thanks guys.

The "F*ing Manual" says nothing about not using Serial in the interrupt.

Really?

other interrupts will be executed after the current one finishes in an order that depends on the priority they have.

For more information on interrupts, see Nick Gammon's notes.

When writing an Interrupt Service Routine (ISR):

Keep it short
Don't use delay ()
Don't do serial prints