{"id":79,"date":"2020-09-04T02:00:24","date_gmt":"2020-09-04T02:00:24","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=79"},"modified":"2021-07-14T00:45:28","modified_gmt":"2021-07-14T00:45:28","slug":"understanding-the-systick-timer","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=79","title":{"rendered":"Understanding the Systick Timer"},"content":{"rendered":"\n<p>The System tick timer is present in all arm cortex-m microcontrollers. Irrespective of whether it is STM32,LPC, Tiva C etc.<\/p>\n\n\n\n<p>The System tick timer allows the system to initiate an action on a periodic basis. This action is performed internally at a fixed rate without external signal. For example, in a given application we can use SysTick to read a sensor every 200 msec. SysTick is used widely by operating systems so that the system software may interrupt the application software periodically (often 10 ms interval) to monitor and control the system operations. The SysTick is a 24-bit down counter driven by either the system clock or the internal oscillator. It counts down from an initial value to 0. When it reaches 0, in the next clock, it underflows and it raises a flag called COUNT and reloads the initial value and starts all over.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bohobiom.com\/wp-content\/uploads\/2020\/01\/Slide30-1024x576.png\" alt=\"\" width=\"753\" height=\"423\"\/><\/figure>\n\n\n\n<p><strong>Systick Register<\/strong><\/p>\n\n\n\n<p>Lets see the systick registers. There are three registers in the SysTick module: SysTick Control and Status register, SysTick Reload Value register, and SysTick Current Value register.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bohobiom.com\/wp-content\/uploads\/2020\/01\/Slide31-1024x576.png\" alt=\"\" width=\"766\" height=\"431\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bohobiom.com\/wp-content\/uploads\/2020\/01\/Slide32-2-1024x576.png\" alt=\"\" width=\"843\" height=\"474\"\/><\/figure>\n\n\n\n<p><strong>SYSTICK IMPLEMENTATION<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&lt;br&gt;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\"> \/* Configure SysTick to generate 500 ms delay to\n * toggle the board LED.  *\/\n#include &quot;stm32f4xx.h&quot;\nint main(void) {\n    RCC-&gt;AHB1ENR |=  1;             \/* enable GPIOA clock *\/\n    GPIOA-&gt;MODER &amp;= ~0x00000C00;    \/* clear pin mode *\/\n    GPIOA-&gt;MODER |=  0x00000400;    \/* set pin to output mode *\/\n    \/* Configure SysTick *\/\n    SysTick-&gt;LOAD = 3200000 - 1; \/* reload with number of clocks per second *\/\n    SysTick-&gt;VAL = 0;\n    SysTick-&gt;CTRL = 5;     \/* enable it, no interrupt, use system clock *\/\n\n    while (1) {\n        if (SysTick-&gt;CTRL &amp; 0x10000) {  \/* if COUNT flag is set *\/\n            GPIOA-&gt;ODR ^= 0x00000020;   \/* toggle green LED *\/\n        }\n    }\n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The System tick timer is present in all arm cortex-m microcontrollers. Irrespective of whether it is STM32,LPC, Tiva C etc. The System tick timer allows the system to initiate an action on a periodic basis. This action is performed internally at a fixed rate without external signal. For example, in a given application we can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,12],"tags":[10,13],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-peripheral-drivers","category-stm32","tag-peripheral-drivers","tag-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/79"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}