Ok so I have an "arduino" and it is running @ 8mhz (i say it like that cause its not, its a tiny84 but for the point of this topic that is not need to know)
I am trying to cook up a ADB (apple desktop bus) interface, ADB is a 1 wire fun little serial protocol. Timing and flags are an important fact to get communications
When the machine first turns on I have a chance to sample the device 0 / reset signal which contains an Attention flag, a Sync Flag, and a command byte of 00001111, which is separated by a bit cell time period (lost yet?)
using the following test sketch I am reading the signal from the Macintosh and gathering the Attention flag, the Sync flag, and the Bit cell time,during void setup(), and during void loop I have the mcu output its findings on another pin
#define adbData 0
#define out 3
unsigned long atnSignal;
unsigned long syncSignal;
unsigned long bitCell;
void setup()
{
pinMode(adbData, INPUT);
pulseIn(adbData, HIGH); // waiting for bus to come online
atnSignal = pulseIn(adbData, LOW);
syncSignal = pulseIn(adbData, HIGH);
bitCell = (pulseIn(adbData, LOW) + pulseIn(adbData, HIGH));
pinMode(out, OUTPUT);
}
void loop()
{
PORTA = 0x80; // pin 3 for attiny on
delay(1);
PORTA = 0x00; // pin 3 for attiny off
delayMicroseconds(atnSignal);
PORTA = 0x80;
delayMicroseconds(syncSignal);
PORTA = 0x00;
delayMicroseconds(bitCell);
}
and here are the results
| * | MAC | AVR | | - | - | - | | ATTN | 648us | 640us | | SYNC | 56us | 48us | | Bcell | 80us | 80us |
now even though were dealing with pieces of 8's here I am a bit disappointed that most of the timings recorded by the arduino are short, so here are the questions
Would I get better timing data by constantly polling the pin and calculate time differences?
On the opposite, would I be able to do better by running the chip at 16mhz while saving code hassle and using pulseIn()?
How reasonable are my expectations and should I just move on
Thanks ;D