Hi all,
(I am sure this has been answered before but I could not find it.)
Using an Arduino Uno, I need to output bit patterns as fast as possible.
(This is to drive several stepper motors.) The bit patterns consist of 3 bits to address a motor, and 4 bits for it's step pattern, then a strobe is toggled.
Currently I do it thus:
const byte pattPin[] = {4, 5, 6, 7}; // Array of pin numbers for motor patterns
const byte motAddr[] = {8, 9, 10}; // Array of pins for motor addr (1 to 6)
const byte strobe = 11; // Data strobe pin
// Find motor pattern and output;
int pIndex = motPos[mot] & 7;
byte mPat = motPatt[pIndex];
digitalWrite(pattPin[0], bitRead(mPat, 0));
digitalWrite(pattPin[1], bitRead(mPat, 1));
digitalWrite(pattPin[2], bitRead(mPat, 2));
digitalWrite(pattPin[3], bitRead(mPat, 3));
//Output motor addr
digitalWrite(motAddr[0], bitRead(mot, 0));
digitalWrite(motAddr[1], bitRead(mot, 1));
digitalWrite(motAddr[2], bitRead(mot, 2));
// Strobe the data through:
digitalWrite(strobe, LOW);
digitalWrite(strobe, HIGH);
If I have this correct, the 4-bit motor pattern is on ATmega168 port D4,5,6,7 and the 3-bit motor address on port B0,1,2 and strobe on B3.
Please can you show me how to do this in embedded assembler by passing variables?
Many thanks,
- jon.