In the SysCtlDelay documentation, you can read "The loop takes 3 cycles / loop."In simulator, it takes 4 cycles / loop.I'm wrong?
CharlesA. said:In the SysCtlDelay documentation
Give a link - so that people can see exactly what you're looking at, and in context.
CharlesA. said:In simulator, it takes 4 cycles / loop
How, exactly, do you determine that?
I am working with the Keil MDK-Lite version 5.24.2 uVision toolchain, I am working with a Stellaris® LM4F120 LaunchPad Evaluation Board from Texas Instruments. The microcontroller is tm4c123gh6pm.The software used is an example (Project0) supplied by Texas in Stellarisware and it is:
intmain(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); }}
The execution of each Delay in the simulator occupies a time of 8000000 states. Executing the Delay loop step by step, it is also observed that each loop occupies 4 states.
Stellarisware? That's a blast from the past!
CharlesA. said:The software used is an example (Project0) supplied by Texas in Stellarisware
So have you asked Texas Instruments about this?
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); } }
Again, that's TI's software - so you should be asking them about it, and/or for clarifications on their documentation!
By measuring the switching time of the port with an oscilloscope, it is confirmed that Delay actually occupies 3 cycles / loop.And in the simulation 4 cycles / loop.