STM32 peripheral driver---SysTick precise delay

Publisher:genius5Latest update time:2019-02-14 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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();

}


Keywords:STM32 Reference address:STM32 peripheral driver---SysTick precise delay

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

STM32 RTC reading and writing incorrectly
When debugging RTC, I found that the reading and writing were incorrect. Reading and writing are library functions that are called, and the year, month, day, hour, minute, and second are operated separately When reading and writing, it is found that after the year, month and day are written, it takes several secon
[Microcontroller]
STM32 learning record 12 interrupt vector table
From stm32f10x.s, we can see that a lot of interrupt response functions have been defined. This is the interrupt vector table, labeled __Vectors, which indicates the entry address of the interrupt vector table, for example: AREA RESET, DATA, READONLY ; Define the read-only data segment, which is actually in the CODE a
[Microcontroller]
STM32 learning record 12 interrupt vector table
STM32 Real-time Clock RTC
RTC (Real Time Clock) and Backup Registers  The RTC and backup registers are powered by a switch that selects VDD power when VDD is valid, otherwise the VBAT pin is used for power supply. Backup registers (10 16-bit registers) can be used to save data when VDD disappears.  The real-time clock has a set of co
[Microcontroller]
stm32 usb data buffer question
Different USB applications require different endpoint numbers and endpoint data lengths. It is very wasteful to plan a separate storage area for each endpoint. Therefore, STM32 provides a total of 512 bytes of storage area for the USB module. As for how to allocate and use this 512B space for each endpoint, it is up
[Microcontroller]
Solve the problem that STM32 J-FLASH cannot read RAM download
I made two ARM-OB downloaders and STLINK downloaders in the afternoon. I thought it would be done quickly, but the following problems occurred in the last step: - ERROR: RAM check failed @ address 0x20000000. - ERROR: Write: 0xE7FEBE00 E07CE062        - ERROR: Read: 0x0000000 000000000        - ERROR: (0 bytes of
[Microcontroller]
Solve the problem that STM32 J-FLASH cannot read RAM download
STM32 PWM input capture
The STM32 timer has a PWM input capture mode. PWM input capture is a special case of timer input capture, which is specifically used to measure the frequency and duty cycle of the PWM wave (the chip design is really user-friendly). In the previous blog post, I used input capture to measure the frequency of the input PW
[Microcontroller]
STM32 PWM input capture
Definition of STM32 CPU ID, Unique ID, Flash size register
Note that CPU ID and Unique ID have different definitions for ST. The CPU ID is built-in to CortexM3, and the reset value is consistent. There are definitions in PM0056.pdf. Unique ID is a different ID for each chip, which is defined in RM0008.PDF. For example, F103 is defined in Section 30.2. Flash size register is
[Microcontroller]
STM32-FSMC-NANDFLASH
The STM32 FSMC supports two NAND flash blocks, supports hardware ECC and can detect up to 8K bytes of data Its address mapping is shown in the figure below Figure 161 FSMC storage block NAND and PC Card Address Mapping Table 88 Memory map and timing registers  For NAND flash memory, the general and attribute
[Microcontroller]
STM32-FSMC-NANDFLASH
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号