Function prototype:
void SysCtlDelay (unsigned long ulCount)
Parameters:
ulCount is the number of iterations of the delay loop to be executed.
Description:
This function provides a method to generate a constant length delay. It is written in assembly to keep the delay consistent across toolchains
, thus avoiding the need to adjust the delay in the application based on the toolchain.
The loop takes 3 cycles/loop.
Returns:
None.
void Delay(unsigned long nCount)
{
for(; nCount != 0; nCount--);
}
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
/* For debugging PF1 <-> LED ---- --------------------------------------------------* /
#define LED_PERIPH SYSCTL_PERIPH_GPIOF
#define LED_PORT GPIO_PORTF_BASE
#define LED_PIN GPIO_PIN_1
#define LED_OFF 1 << 1
#define LED_ON ~(1 << 1) // Low level lights LED
void Delay(unsigned long nCount)
{
for(; nCount != 0; nCount--);
}
int main(void)
{
// Set the clocking to run directly from the crystal.
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(LED_PERIPH); // Enable the GPIO port where the LED is located
GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN); // Set the LED pin to output
while (1)
{
GPIOPinWrite(LED_PORT, LED_PIN, LED_ON); // Click Turn on LED
Delay(0xfff); // The experimental delay is 2.5ms
GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF); // Turn off LED
Delay(0xfff); // The experimental delay is 2.5ms
/*
GPIOPinWrite(LED_PORT, LED_PIN , LED_ON); // Turn on LED
SysCtlDelay(SysCtlClockGet() / 3000); // Accurate delay 1ms
GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF); // Turn off LED
SysCtlDelay(SysCtlClockGet() / 3000); // Accurate delay 1ms
*/
}
}
System clock | 16M | 50M |
Count delay: Delay(0xfff); | 2.5ms | 819us |
System delay: SysCtlDelay(SysCtlClockGet() / 3000); | 1ms | 1ms |
//********************************************************************************
//
// Accurate delay nms
//
//********************************************************************************
void Delay(DWORD nms)
{
SysCtlDelay((SysCtlClockGet() / 3000) * nms);
}
Previous article:LM3S9B96 UART print string function
Next article:LM3S9B96 IAR Create a new project
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- Testing methods and diagnostic analysis for DSP-containing circuit boards
- Fundamentals of Circuits and Analog Electronics Technology
- LAUNCHXL-F28379D comprehensive routine
- 【DWIN Serial Port Screen】One of the Nucleic Acid Sampling and Registration Systems
- Live broadcast at 10 am today [TI's new generation MSP430 helps low-cost ultrasonic water meter]
- Playing with Zynq Serial 24 - Porting of User-Defined IP Cores
- Running PyBasic with CircuitPython on PyPortal
- LM3630A overcurrent abnormality detection problem
- 【Qinheng CH582】Structural analysis of Bluetooth protocol stack
- I would like to invite the great moderator eric_wang to answer what the northbound and southbound often used in NB-IOT mean