I have a device I’m trying to control with the Arduino.
It works like this.
- Arduino sets and holds ‘ready line’ to 5V high.
- Device sees ready line high and sends 16 clock pulses for two bytes of messages to receive at a rate of about 8.3Khz.
- On each clock pulse the Arduino sets the data output to whatever the bit should be (0 or 1)
- When the two bytes have been sent, the ‘ready line’ is set back to 0v low.
The problem I have is getting the Arduino to sync to the clock pulses. With some Googling I came across interrupts.
The thing is I’ve read you can’t pass arguments to a interrupt function, not even global variables?
My idea would be to prepare the byte to be transmitted in an array and then send the ready line high and when the first clock pulse falling edge was received it would trigger an interrupt to output the bit.
To do this though I would need to be able to tell the interrupt what state to output (0 or 1) and to increment the counter so it would know what place of the byte it was at.