Hello,
I have a problem controlling the clock speed. The clock works 4 times faster than I want it to work. For example in the code below, I want the LEDs to turn on for 1 second and then turn off for 1 second, but it turns on and off twice in on second. The clock speed is 16 MHz, I have used SYSCTL_SYSDIV_64 so that should bring the clock speed down to 250 kHz; so if I say SysCtlDelay(250000), shouldn't I get 1 second since there are 250000 tics every second? I face the same problem when using PWM and other features. I'd appreciate any help and thanks in advance.
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_64|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
HWREG ( GPIO_PORTF_BASE + GPIO_O_LOCK ) = GPIO_LOCK_KEY ;
HWREG ( GPIO_PORTF_BASE + GPIO_O_CR ) |= 0x01 ;
HWREG ( GPIO_PORTF_BASE + GPIO_O_LOCK ) = 0;
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1);
while(1)
{
// Turn on the LED
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1, 0xFF);
// Delay for a bit
SysCtlDelay(250000);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1, 0x00);
// Delay for a bit
SysCtlDelay(250000);
}
}