Part Number:EK-TM4C123GXL
Hi all, a question about the shortest amount of time one can "wait" using the TM4C123G. The processor can be configured to run at a max speed of 80 MHz using the following:
(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
...and the shortest way I know to "wait" is to use:
SysCtlDelay(1);
So, if the processor is running at 80 MHz, that means 12.5 nanoseconds per cycle. But clearly a line of code will take more than one cycle to execute and, if I understand correctly, an assembly instruction will take more than one cycle to execute. For what it's worth the assembly of the SysCtlDelay(1) line of code is this:
SysCtlDelay(1);
0000057a: 2001 movs r1, #1
0000057c: F000F958 bl #0x830
SysCtlDelay():
00000830: 1E40 subs r0, r0, #1
00000832: D1FD bne SysCtlDelay
00000834: 4770 bx lr
The way I time sections of code is toggling a pin which is hooked up to my logic analyzer. Example code:
while(1)
{
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7, 0x80);
SysCtlDelay(1);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7, 0x00);
SysCtlDelay(1);
}
^This is simply setting the PA7 pin high and then setting it low with the shortest possible wait in between. When measuring this with my logic analyzer I see the pin is high for 280 nanoseconds and then low for 360 nanoseconds. I suppose that seems about right, agree? This would mean the little block of assembly above, plus whatever assembly is required to toggle the pins on/off are taking roughly a few hundred nanoseconds, or cycle wise, ~300/12.5 = ~24 cycles.
Just wondering if my analysis here is correct and if there is any other way to wait for a shorter period than a few hundred nanoseconds?