当前位置:网站首页>51 timer initial value calculation
51 timer initial value calculation
2022-07-25 06:19:00 【sinat_ twenty-six million five hundred and twenty-eight thousan】
#define FOSC 11059200L
#define T1MS (65536-FOSC/12/1000) //1ms timer calculation method in 12T mode
stay 51 See such a code in the technical manual of single chip microcomputer ,
It means , Timer implementation 1 Millisecond timing , Find the initial value of the timer .
Because the timer counts 65536 after , It will be cleared , Want to achieve specific timing , You have to calculate the starting point by yourself , Also called initial value
because 1 One machine cycle is equal to 12 Clock cycles , therefore FOSC/12, What you get is the frequency of a machine cycle , It's also 1 The number of seconds counted by the timer , Divided by 1000, Namely 1 The number of timers counted in milliseconds .
Want the timer to clear after these numbers , Set the starting point as 65536- The number .
So you get 65536-FOSC/12/1000
Empathy , Want to set 5 Millisecond timer ,65536-5*FOSC/12/1000
In this way, I get , Want to set t Millisecond timer ,65536-t*FOSC/12/1000
Be careful , The timer has an upper limit , The maximum is 65536*FOSC/12 millisecond , Because a machine cycle is FOSC/12 millisecond , The timer counts at most 65536 Time , Will overflow , from 0 Start counting .
边栏推荐
- Sword finger offer 54. the k-th node of the binary search tree
- Sword finger offer 45. arrange the array into the smallest number
- What does "TTL" mean in domain name resolution?
- Sword finger offer 36. binary search tree and bidirectional linked list
- VBA common objects
- SAP FICO section III BDC and ltmc import S4 financial account
- Ida Pro novice tutorial
- U-boot-1.1.6 transplant notes (beginner)
- Scientific computing library numpy Foundation & Improvement (Understanding + explanation of important functions)
- Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
猜你喜欢

JTAG debugging source level debugging of arm bare board debugging

Use abp Zero builds a third-party login module (4): wechat applet development
![(15) [driver development] over written copy](/img/1c/68dfff5671add1fe91567e4df34135.png)
(15) [driver development] over written copy

都说ScreenToGif是GIF录制神器,却不知其强大之处远不在此

(2022 Niuke multi School II) k-link with bracket sequence I (dynamic planning)

(2022牛客多校二)L-Link with Level Editor I(动态规划)
![[ultra detailed diagram] FPN + mask RCNN](/img/ef/ddd62fe7e54074c134aa5ee4cc5840.png)
[ultra detailed diagram] FPN + mask RCNN

(Niuke multi School II) j-link with arithmetic progress (least square method / three points)

Unity model simplification / consolidation one click plug-in

Evolution of coupon architecture under C2B mode
随机推荐
Vbs script COM object extension and use (3)
(牛客多校二)G-Link with Monotonic Subsequence(构造题)
Leetcode/ binary addition
【datawhale202207】强化学习:强化学习基础
leetcode/ 前 n 个数字二进制中 1 的个数
Blocking Queue Analysis
Typedef usage and template
JVM tuning summary -xms -xmx -xmn -xss
日期(DAY 76)
Multithreading programming under Win32 API
Date (day 76)
GF Securities online account opening? Is it safe?
Tutorial: encryption keys in cloud (using golang and CLI)
Netease game Flink SQL platform practice
【Unity3D】UGUI回调函数
"Everyday Mathematics" serial 61: March 1
嵌入式c语言开发之宏定义求两个数的最大值的使用技巧
(2022 Niuke multi school) D-Link with game glitch (SPFA)
Koa2 learning
JS gets the text selected by the mouse and is in the selected state