当前位置:网站首页>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);
}
边栏推荐
- 【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- 嵌入式开发用到的一些工具
- How Kolo enables NFT music industry
- 富文本实现插值
- 【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- 2.4 activation function
- SQL learning notes (01) - basic knowledge of database
- SDN_简单总结
- 2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
- How to realize the usage of connecting multiple databases in idel
猜你喜欢
Nacos service configuration and persistence configuration
NoSQL数据库的安装和使用
JS prototype chain
OSPF - virtual link details (including configuration commands)
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
Swift control encapsulation - paging controller
How to launch circle of friends marketing and wechat group activities
树结构---二叉树2非递归遍历
随机推荐
SQL learning notes (01) - basic knowledge of database
LVGL V8.2字符串显示在Keil MDK上需要注意的事项(以小熊派为例)
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
js 使用toString 区分Object、Array
The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
Problems caused by delete and delete[]
Concept of digital currency
Network counting 01 physical layer
JS variable lifting
JS use toString to distinguish between object and array
Youqitong PE toolbox [vip] v3.7.2022.0106 official January 22 Edition
树结构---二叉树1
Click the screen with your finger to simulate F11 and enter the full screen
短路运算符惰性求值
Error org apache. catalina. core. StandardContext. FilterStart start filter exception
Mikrotik Routeros Internet access settings
Day06 branch structure and cycle (III)
js作用域链与闭包
2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data