This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Number of clock cycles in the execution of "SysCtlDelay" in the simulator.

In the SysCtlDelay documentation, you can read "The loop takes 3 cycles / loop."
In simulator, it takes 4 cycles / loop.
I'm wrong?

Parents
  • We are also using Tiva and Tivaware, but now I cannot have it.
    However, I suppose it presents the same problem

    int
    main(void)
    {
        //
        // Setup the system clock to run at 50 Mhz from PLL with crystal reference
        //
      SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    
        //
        // Enable and configure the GPIO port for the LED operation.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);
    AL = 1;
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
    
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, BLUE_LED);
    AL = 0;
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
        }
    }
    

Reply
  • We are also using Tiva and Tivaware, but now I cannot have it.
    However, I suppose it presents the same problem

    int
    main(void)
    {
        //
        // Setup the system clock to run at 50 Mhz from PLL with crystal reference
        //
      SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    
        //
        // Enable and configure the GPIO port for the LED operation.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);
    AL = 1;
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
    
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, BLUE_LED);
    AL = 0;
            //
            // Delay for a bit
            //
            SysCtlDelay(2000000);
        }
    }
    

Children