Hey guys,
I'm looking to use a Teensy 3.2 to write 16 bits of parallel data out at between 10MHz and 40MHz.
To test if this is possible I've written what 'I' think to be the fastest toggling of a pin possible but can only seem to achieve at best 10.3MHz
This is compiled with -DF_CPU=144000000 and -O3 to produce:
Am I going about this the wrong way? Or can this be sped up?
I'm looking to use a Teensy 3.2 to write 16 bits of parallel data out at between 10MHz and 40MHz.
To test if this is possible I've written what 'I' think to be the fastest toggling of a pin possible but can only seem to achieve at best 10.3MHz
Code:
void setup() {
// configure the 8 output pins of Port D
pinMode(2, OUTPUT); // #0
pinMode(14, OUTPUT); // #1
pinMode(7, OUTPUT); // #2
pinMode(8, OUTPUT); // #3
pinMode(6, OUTPUT); // #4
pinMode(20, OUTPUT); // #5
pinMode(21, OUTPUT); // #6
pinMode(5, OUTPUT); // #7
GPIOD_PDOR = 0x00000000;
pinMode(pclkInterruptPin, INPUT);
}
void loop() {
noInterrupts();
clocking();
}
FASTRUN static void clocking(void) {
begin:
asm (
"mvns %0, %0\n\t" // Invert Port D
: "+r" (GPIOD_PDOR)
:
);
goto begin;
}
This is compiled with -DF_CPU=144000000 and -O3 to produce:
Code:
1fff8760 <_ZL8clockingv>:
1fff8760: 4a02 ldr r2, [pc, #8] ; (1fff876c <_ZL8clockingv+0xc>)
1fff8762: 6813 ldr r3, [r2, #0]
1fff8764: 43db mvns r3, r3
1fff8766: 6013 str r3, [r2, #0]
1fff8768: e7fb b.n 1fff8762 <_ZL8clockingv+0x2>
Am I going about this the wrong way? Or can this be sped up?
Last edited: