Hi all, I'm playing with the teensy 4.0 which is fab (thank you Paul).
I'm trying to write a 12 bit value to pins 0 to 11.
I've done some reading and the only way I can figure out how to do it is like this ;
which is ugly as hell and also VERY slow and takes about 3.9uS to complete.
Is there anyway to write to a set of pins directly?
I've had a scour on here, and I can't find an answer
Many thanks in advance
Paula
I'm trying to write a 12 bit value to pins 0 to 11.
I've done some reading and the only way I can figure out how to do it is like this ;
Code:
if(data & 0x0001)
digitalWriteFast(0,HIGH);
else
digitalWriteFast(0,LOW);
if(data & 0x0002)
digitalWriteFast(1,HIGH);
else
digitalWriteFast(1,LOW);
if(data & 0x0004)
digitalWriteFast(2,HIGH);
else
digitalWriteFast(2,LOW);
if(data & 0x0008)
digitalWriteFast(3,HIGH);
else
digitalWriteFast(3,LOW);
if(data & 0x0010)
digitalWriteFast(4,HIGH);
else
digitalWriteFast(4,LOW);
if(data & 0x0020)
digitalWriteFast(5,HIGH);
else
digitalWriteFast(5,LOW);
if(data & 0x0040)
digitalWriteFast(6,HIGH);
else
digitalWriteFast(6,LOW);
if(data & 0x0080)
digitalWriteFast(7,HIGH);
else
digitalWriteFast(7,LOW);
if(data & 0x0100)
digitalWriteFast(8,HIGH);
else
digitalWriteFast(8,LOW);
if(data & 0x0200)
digitalWriteFast(9,HIGH);
else
digitalWriteFast(9,LOW);
if(data & 0x0400)
digitalWriteFast(10,HIGH);
else
digitalWriteFast(10,LOW);
if(data & 0x0800)
digitalWriteFast(11,HIGH);
else
digitalWriteFast(11,LOW);
which is ugly as hell and also VERY slow and takes about 3.9uS to complete.
Is there anyway to write to a set of pins directly?
I've had a scour on here, and I can't find an answer
Many thanks in advance
Paula