当前位置:网站首页>Cortex M4 systick details
Cortex M4 systick details
2022-07-01 09:35:00 【stone8761】
Cortex M4 Provides SysTick function ,SysTick It's a 24bits Timer , A cycle interrupt can be provided by simple programming , Commonly used as an operating system ” heartbeat “.
One 、 register
1、STK_CTRL

2、STK_LOAD

3、STK_VAL

Two 、 Clock source
SysTick Two clock sources can be selected , Through registers STK_CTRL Of CLKSOURCE To choose ,‘0’ Indicates that the clock source is AHB(HCLK) Of 1/8,'1' Indicates that the clock source is AHB(HCLK).
3、 ... and 、 Reload and interrupt
Through registers STK_CTRL Of ENABLE Set up ‘1' You can start SysTick. After starting SysTick Value is subtracted by one per clock cycle , The duty of ‘0’ Will register STK_CTRL Of COUNTFLAG Set up . If enabled at this time SysTick Interrupts trigger interrupts . You can set the register STK_CTRL Of TICKINT Location ‘1’ Can make SysTick interrupt .SysTick After counting to 0 The next clock cycle of will start from STK_LOAD Load value in register .
Four 、 Cycle interruption
Can make SysTick After the interrupt is turned on, a cycle interrupt will be generated , Cycle frequency and clock source and STK_LOAD The value of , The formula is as follows :
F = FSRC / (STK_LOAD + 1)
The code is as follows :
uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload whether the value is valid (24 position )*/
}
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* Set reload value */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* Set up SysTick Interrupt priority */
SysTick->VAL = 0UL; /* Clear the counter */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | /* Set up SysTick From AHB(HCLK) */
SysTick_CTRL_TICKINT_Msk | /* Can make SysTick interrupt */
SysTick_CTRL_ENABLE_Msk; /* start-up SysTick */
return (0UL);
}边栏推荐
- Day06 branch structure and cycle (III)
- js 使用toString 区分Object、Array
- ES6-const本质与完全不可改实现(Object.freeze)
- Imitation of Baidu search results top navigation bar effect
- 【pytorch】nn. Crossentropyloss() and nn NLLLoss()
- 队列的实现和应用
- SQL learning notes (03) -- data constraint relationship
- 【pytorch】nn.AdaptiveMaxPool2d
- JS prototype inheritance can only inherit instances, not constructors
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
猜你喜欢

The market is relatively weak recently

JS prototype chain

3D打印Arduino 四轴飞行器

How to launch circle of friends marketing and wechat group activities

嵌入式开发用到的一些工具

Simple load balancing with Nacos

Principles of Microcomputer - Introduction

奇怪,为什么ArrayList初始化容量大小为10?

Error org apache. catalina. core. StandardContext. FilterStart start filter exception

Principle and application of single chip microcomputer timer, serial communication and interrupt system
随机推荐
Introduction to mt7628k eCos development
MapReduce编程基础
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
js 使用toString 区分Object、Array
SQL learning notes (04) - data update and query operations
Implementation and application of queue
js this丢失问题分析 及 解决方案
UE small knowledge point controller possess pawn process
Construction of esp8266 FreeRTOS development environment
Simple load balancing with Nacos
[untitled]
Unity tips for reducing the amount of code -- empty protection extension
短路运算符惰性求值
手指点击屏幕就模拟进入F11进入全屏
类加载
Daily practice of C language - day 80: currency change
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Log4j 日志框架
Leetcode daily question brushing record --540 A single element in an ordered array
Meituan machine test in 2022