Hi everyone,
I'm working on a project using the TM4C123BH6PGE microcontroller and have encountered a weird issue with timing delays. I'm utilizing `SysCtlDelay` for implementing a simple delay function, but I've observed that the delay duration has unexpectedly doubled after I commented out some LED blinking code. I'm hoping to get some insights or suggestions on what might be causing this behavior.
Clock Configuration:
My system clock is configured as follows:
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
```
System Clock Initialization:
g_ui32SysClock = SysCtlClockGet(); // This fetches the system clock rate
Delay Function:
void Timer_SimpleDelay(uint32_t milliseconds)
{
uint32_t sleep = (g_ui32SysClock / 3000) * milliseconds;
SysCtlDelay(sleep);
}
I use this function to create a delay, for example, `Timer_SimpleDelay(3000);` for a 3-second delay. However, measurements show it waits for 6 seconds instead of 3.
This timing discrepancy started when I commented out my LED blinking code, which looks like this:
void MainLoopLedRunner()
{
if(u8LedDelayCount % 40 == 0)
{
if(!bLedStatus)
{
GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_1, GPIO_PIN_1);
bLedStatus = true;
}
else
{
GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_1, 0x0);
bLedStatus = false;
}
u8LedDelayCount = 0;
}
u8LedDelayCount++;
}
Can anyone help explain why removing the LED blinking function would result in the `SysCtlDelay` timing being doubled? It seems unrelated at first glance, but the issue is consistently reproducible. What am I missing here?
Thanks in advance for any advice or insights you can provide!

