Microcontroller: STM32F103
Library functions: V3.5
Description: Use the SysTick in the system kernel file core_cm3.c to achieve 1ms, 1us accurate delay, clock 72MHz, involving the registration of the interrupt service SysTick_Handler.
delay.h
#ifndef __DELAY_H__
#define __DELAY_H__
#include "stm32f10x.h"
extern void DelayMs(__IO uint32_t nTime);
extern void DelayUs(__IO uint32_t nTime);
//this function for systick handler function
extern void TimingDelay_Decrement(void);
#endif
delay.c
#include "delay.h"
static __IO uint32_t TimingDelay;
void DelayMs(__IO uint32_t nTime)
{
if (SysTick_Config(72000))
{
/* Capture error */
while (1);
}
TimingDelay = nTime;
while(TimingDelay != 0);
}
void DelayUs(__IO uint32_t nTime)
{
if (SysTick_Config(72))
{
/* Capture error */
while (1);
}
TimingDelay = nTime;
while(TimingDelay != 0);
}
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
Interrupt service stm32f10x_it.c
void SysTick_Handler(void)
{
TimingDelay_Decrement();
}
Previous article:Summary of the STM32F103 MCU system clock
Next article:Notes on wiring for st-link and jlink debugging stm32
Recommended ReadingLatest update time:2024-11-15 14:20
- 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
- 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
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- TI 2803x DSP chip LIN communication baud rate adaptation
- [RISC-V MCU CH32V103 Evaluation] External interrupt control waveform output
- USB 4G module testing based on TI Sitara Cortex-A8
- [2022 Digi-Key Innovation Design Competition] Intimate Photo Frame - Internet Weather Digital Photo Frame Based on STM32H745 (Final Version)
- Are UWB devices the future trend?
- Please tell me what's going on.
- KEE Master Classroom: Verify the RF properties of IoT devices during manufacturing faster and easier
- How to create a new TMS320F28379D project in CCS
- I'm a novice and I need help on how to install Grace on CCS10. Thanks in advance.
- DCA1000EVM User Guide