{"id":475773,"date":"2026-04-13T15:16:02","date_gmt":"2026-04-13T15:16:02","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=475773"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=475773","title":{"rendered":"\u0416\u0438\u0437\u043d\u044c \u0431\u0435\u0437 CubeMX: \u041a\u0430\u043a \u043f\u0440\u043e\u0448\u0438\u0442\u044c STM32, \u0438\u043c\u0435\u044f \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043b\u043e\u043a\u043d\u043e\u0442"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0438\u0442\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0441\u0431\u0440\u043e\u0441\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u0432\u0445\u043e\u0434\u0430 \u0432 <code>main()<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f\u0434\u0440\u043e Cortex-M3 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u0431\u0440\u043e\u0441\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 startup-\u043a\u043e\u0434.<\/p>\n<p>\u0412 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c bare-metal \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0431\u0435\u0437 HAL \u0438 \u0431\u0435\u0437 CubeMX \u0432\u0441\u044f \u044d\u0442\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e \u0448\u0430\u0433\u0430\u043c. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441\u043e STM32: \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438\u043d\u043a\u0435\u0440, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d startup \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 C-\u043a\u043e\u0434 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u201c\u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435\u201d.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043d\u0443\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 linker script;<\/p>\n<\/li>\n<li>\n<p>startup-\u0444\u0430\u0439\u043b;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0443\u0447\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>.data<\/code> \u0438 <code>.bss<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GPIO;<\/p>\n<\/li>\n<li>\n<p>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c \u043d\u0430 PC13;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0443\u0441\u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 TIM2.<\/p>\n<\/li>\n<\/ul>\n<p>\u0426\u0435\u043b\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u0433\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434. \u0426\u0435\u043b\u044c \u2014 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0438 \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434. <strong>\u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/strong> \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e \u0446\u0435\u043d\u0435 \u0447\u0430\u0448\u043a\u0438 \u043a\u043e\u0444\u0435 <strong>STM32F103C8T6.<\/strong>  <\/p>\n<h3>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u0435<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u043d\u0430 PC13;<\/p>\n<\/li>\n<li>\n<p>\u0436\u0434\u0430\u0442\u044c 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043d\u043e\u0432\u0430 \u0436\u0434\u0430\u0442\u044c 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0443\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0451\u0432:<\/p>\n<pre><code>full_program_from_scratch\/\u251c\u2500\u2500 inc\/\u2502   \u251c\u2500\u2500 config.h\u2502   \u251c\u2500\u2500 GPIO.h\u2502   \u251c\u2500\u2500 LED.h\u2502   \u251c\u2500\u2500 main.h\u2502   \u2514\u2500\u2500 Timers.h\u251c\u2500\u2500 src\/\u2502   \u251c\u2500\u2500 config.c\u2502   \u251c\u2500\u2500 GPIO.c\u2502   \u251c\u2500\u2500 LED.c\u2502   \u251c\u2500\u2500 main.c\u2502   \u2514\u2500\u2500 Timers.c\u251c\u2500\u2500 startup\/\u2502   \u2514\u2500\u2500 startup.c\u251c\u2500\u2500 myLinker.ld\u251c\u2500\u2500 firmware.elf\u2514\u2500\u2500 firmware.bin<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0438\u0434\u0435\u044f bare-metal \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h3>\n<p>\u0412 bare-metal-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0435\u0439 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0438\u0434 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">*(volatile uint32_t*)0x40021018 |= (1 &lt;&lt; 4);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<\/p>\n<h4>volatile<\/h4>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>volatile<\/code> \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u201c\u0443\u043c\u043d\u044b\u0435\u201d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e, \u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u0438 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0435\u043c\u0443 \u0432\u044b\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u0442\u0430\u0440\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e, \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<h4>uint32_t<\/h4>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 STM32F1 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 32 \u0431\u0438\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e <code>uint32_t<\/code>.<\/p>\n<h4>0x40021018<\/h4>\n<p>\u042d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <code>RCC_APB2ENR<\/code>. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0430 \u0448\u0438\u043d\u0435 APB2.<\/p>\n<h4>(1 &lt;&lt; 4)<\/h4>\n<p>\u0411\u0438\u0442 4 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0440\u0442\u0443 GPIOC. \u041f\u043e\u043a\u0430 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f GPIOC \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 clock \u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u0440\u0443\u0431\u043e\u0432\u0430\u0442\u043e, \u0437\u0430\u0442\u043e \u043e\u043d \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f: \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u201c\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u201d, \u0430 \u043c\u0435\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0431\u0438\u0442 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<p>\u041f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e\u0442 \u0441\u0442\u0438\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0414\u043b\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 TIM2 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e: \u0432\u043c\u0435\u0441\u0442\u043e \u0433\u043e\u043b\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <code>TIM2<\/code>.<\/p>\n<h2>Linker script: \u043a\u0430\u0440\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>Linker script \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043b\u0438\u043d\u043a\u0435\u0440\u0443, \u0433\u0434\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0435\u0436\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 <code>.text<\/code>, <code>.data<\/code>, <code>.bss<\/code>, <code>.isr_vector<\/code> \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e STM32.<\/p>\n<p>\u0423 linker script \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e \u044d\u0442\u0438\u043c \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0434\u043b\u044f startup-\u043a\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043b\u0438\u043d\u043a\u0435\u0440 \u0444\u0430\u0439\u043b:<\/p>\n<\/li>\n<\/ul>\n<pre><code>_estack = = ORIGIN(RAM) + LENGTH(RAM);MEMORY{    FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x00010000    RAM   (rwx): ORIGIN = 0x20000000, LENGTH = 0x00005000}SECTIONS{    .isr_vector :    {        KEEP(*(.isr_vector))    } &gt; FLASH    .text :    {        *(.text)        *(.text*)    } &gt; FLASH    .rodata :    {        *(.rodata)        *(.rodata*)    } &gt; FLASH    .data :    {        _sdata = .;  \/\/\u0422\u043e\u0447\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0432 RAM        *(.data)        *(.data*)        _edata = .;    } &gt; RAM AT &gt; FLASH    _sidata = LOADADDR(.data); \/\/\u0422\u043e\u0447\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e FLASH \u043f\u0430\u043c\u044f\u0442\u0438    .bss :    {        _sbss = .;        *(.bss)        *(.bss*)        _ebss = .;    } &gt; RAM}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u041e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438<\/h4>\n<p>\u0414\u043b\u044f STM32F103C8T6 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u041e\u0431\u043b\u0430\u0441\u0442\u044c<\/p>\n<\/th>\n<th>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0434\u0440\u0435\u0441<\/p>\n<\/th>\n<th>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">FLASH<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>0x08000000<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">RAM<\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>0x20000000<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0441\u0442\u0435\u043a, <code>.data<\/code>, <code>.bss<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0441\u0442\u0435\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b:<\/p>\n<pre><code>_estack = ORIGIN(RAM) + LENGTH(RAM);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 RAM \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Cortex-M3 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <code>SP<\/code> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.<\/p>\n<h4>\u0421\u0435\u043a\u0446\u0438\u0438<\/h4>\n<h3>.isr_vector<\/h3>\n<p>\u0417\u0434\u0435\u0441\u044c \u043b\u0435\u0436\u0438\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>KEEP(...)<\/code>.<\/p>\n<h3>.text<\/h3>\n<p>\u0421\u0435\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432\u043e FLASH.<\/p>\n<h3>.rodata<\/h3>\n<p>\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e\u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u043e FLASH.<\/p>\n<h3>.data<\/h3>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 RAM, \u043d\u043e \u0438\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u043e FLASH, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0441\u0435\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>&gt; RAM AT &gt; FLASH<\/code>.<\/p>\n<h3>.bss<\/h3>\n<p>\u041d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043e\u043d\u0438 \u0437\u0430\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b sidata, sdata, edata, sbss, _ebss<\/h3>\n<p>\u042d\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u043d\u043a\u0435\u0440, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 startup-\u043a\u043e\u0434.<\/p>\n<ul>\n<li>\n<p><code>_sidata<\/code> \u2014 \u0430\u0434\u0440\u0435\u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e FLASH;<\/p>\n<\/li>\n<li>\n<p><code>_sdata<\/code> \u2014 \u043d\u0430\u0447\u0430\u043b\u043e <code>.data<\/code> \u0432 RAM;<\/p>\n<\/li>\n<li>\n<p><code>_edata<\/code> \u2014 \u043a\u043e\u043d\u0435\u0446 <code>.data<\/code> \u0432 RAM;<\/p>\n<\/li>\n<li>\n<p><code>_sbss<\/code> \u2014 \u043d\u0430\u0447\u0430\u043b\u043e <code>.bss<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>_ebss<\/code> \u2014 \u043a\u043e\u043d\u0435\u0446 <code>.bss<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0411\u0435\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u043a startup-\u043a\u043e\u0434 \u043d\u0435 \u0441\u043c\u043e\u0433 \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043d\u0443\u043b\u044f\u0442\u044c.<\/p>\n<h3>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c<\/h3>\n<p>*(.data) : \u042d\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u0441\u0435\u043a\u0446\u0438\u0439 \u0441 \u0442\u043e\u0447\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c <code>.data<\/code>. \u0421\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.  <\/p>\n<p>*(.data*) : \u0417\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043b\u044e\u0431\u043e\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u00bb.   <\/p>\n<p> \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430: <code>main.c<\/code> \u0438 <code>sensor.c<\/code>.   \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0437 \u043d\u0438\u0445 <code>main.o<\/code> \u0438 <code>sensor.o<\/code>. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u043a\u043e\u0440\u043e\u0431\u043e\u0447\u043a\u0430 \u0441 \u043d\u0430\u0434\u043f\u0438\u0441\u044c\u044e <code>.data<\/code>.   \u041b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a \u0432\u0438\u0434\u0438\u0442 \u0432\u0430\u0448\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>*(.data)<\/code>.   \u041e\u043d \u0438\u0434\u0435\u0442 \u0432 <code>main.o<\/code>, \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0442\u0442\u0443\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>.data<\/code>, \u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u0432 <code>sensor.o<\/code>, \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0434\u043d\u0443 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e <code>.data<\/code> \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.  <\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 .data \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e .o \u0444\u0430\u0439\u043b\u0430. \u042d\u0442\u0430 \u0441\u0435\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f .data.a. \u0422\u043e\u0433\u0434\u0430, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>*(.data),<\/code>\u043b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c *(.data*).<\/p>\n<hr\/>\n<h2>Startup-\u0444\u0430\u0439\u043b: \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430<\/h2>\n<p>Startup-\u043a\u043e\u0434 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0430\u0447\u0438 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0441\u0431\u0440\u043e\u0441\u0430. \u0414\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>main()<\/code> \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<h3>\u041b\u0438\u043d\u043a\u0435\u0440\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b<\/h3>\n<p>\u0412 startup-\u0444\u0430\u0439\u043b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:<\/p>\n<pre><code>extern uint32_t _estack;extern uint32_t _sidata;extern uint32_t _sdata;extern uint32_t _edata;extern uint32_t _sbss;extern uint32_t _ebss;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435. \u042d\u0442\u043e \u0430\u0434\u0440\u0435\u0441\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u043d\u043a\u0435\u0440\u043e\u043c. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 C-\u043a\u043e\u0434\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h3>\u0412\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/h3>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0438\u0449\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437 \u043d\u0443\u0436\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u0412 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c <code>Reset_Handler<\/code>, <code>NMI_Handler<\/code> \u0438 <code>HardFault_Handler<\/code>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 <code>Default_Handler<\/code>.<\/p>\n<h3>weak alias<\/h3>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code><strong>attribute<\/strong>((weak, alias(\"Default_Handler\")))<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442: \u0435\u0441\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <code>Default_Handler<\/code>.<\/p>\n<p>\u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u0440\u0430\u0437\u0443 \u2014 \u043d\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0439\u0434\u0443\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<h3>Reset_Handler<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>Reset_Handler<\/code>. \u0412 \u043d\u0451\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>.data<\/code> \u0438\u0437 FLASH \u0432 RAM;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c <code>.bss<\/code>.<\/p>\n<\/li>\n<li>\n<p> \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>main()<\/code>.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c main() \u0438 \u0435\u0441\u0442\u044c \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u043e \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0435 \u0432 \u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.<\/p>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 startup.c<\/h3>\n<pre><code class=\"cpp\">#include &lt;stdint.h&gt;extern uint32_t _estack;extern uint32_t _sidata;extern uint32_t _sdata;extern uint32_t _edata;extern uint32_t _sbss;extern uint32_t _ebss;int main(void);void Reset_Handler(void);void Default_Handler(void);void NMI_Handler(void)       __attribute__((weak, alias(\"Default_Handler\")));void HardFault_Handler(void)  __attribute__((weak, alias(\"Default_Handler\")));__attribute__((used, section(\".isr_vector\")))const void* vector_table[] ={    &amp;_estack,    Reset_Handler,    NMI_Handler,    HardFault_Handler};void Reset_Handler(void){    uint32_t* src = &amp;_sidata; \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e FLASH    uint32_t* dst = &amp;_sdata;  \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 RAM    while (dst &lt; &amp;_edata){        *dst++ = *src++;      \/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 FLASH \u0432 RAM    }    dst = &amp;_sbss;    while (dst &lt; &amp;_ebss){  \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0435\u043a\u0446\u0438\u0438 .bss \u0432 RAM        *dst++ = 0;        \/\/\u0417\u0430\u043d\u0443\u043b\u044f\u0435\u043c \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435    }    main();    while (1){    }}void Default_Handler(void){    while (1){    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b: \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/h2>\n<p>\u0412 <code>inc\/<\/code> \u043b\u0435\u0436\u0430\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0418\u0445 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043e\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u043c \u0447\u0430\u0441\u0442\u044f\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041e\u0434\u0438\u043d <code>.c<\/code>-\u0444\u0430\u0439\u043b \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u201c\u0437\u043d\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0433\u043e\u201d \u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e <code>.c<\/code>-\u0444\u0430\u0439\u043b\u0430, \u0435\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0438\u0442\u0430\u043d\u0438\u044f CPU \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0432 \u0430\u0434\u0440\u0435\u0441 <code>0x00000000<\/code>, \u0431\u0435\u0440\u0451\u0442 \u043e\u0442\u0442\u0443\u0434\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0435\u043a. \u0414\u0430\u043b\u0435\u0435 CPU \u0447\u0438\u0442\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 <code>0x00000004<\/code> &#8212; \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 <code>Reset_Handler.<\/code>\u041f\u043e\u0441\u043b\u0435 CPU \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c ResetHandler() \u0438 \u043e\u0442\u0442\u0443\u0434\u0430 \u0443\u0436\u0435 \u043f\u0440\u044b\u0433\u0430\u0435\u0442 \u0432 main().<\/p>\n<h3>inc\/GPIO.h<\/h3>\n<pre><code class=\"cpp\">#ifndef GPIO_H#define GPIO_H#include &lt;stdint.h&gt;void GPIO_init(void);#endif<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>inc\/LED.h<\/h3>\n<pre><code class=\"cpp\">#ifndef LED_H#define LED_H#include &lt;stdint.h&gt;void turnOnLED(void);void turnOffLED(void);#endif<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>inc\/Timers.h<\/h3>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">#ifndef TIMERS_H#define TIMERS_H#include &lt;stdint.h&gt;void TIMERS_init(void);void delayOneSecond(void);typedef struct{    volatile uint32_t CR1;   \/\/ 0x00    volatile uint32_t CR2;   \/\/ 0x04    volatile uint32_t SMCR;  \/\/ 0x08    volatile uint32_t DIER;  \/\/ 0x0C    volatile uint32_t SR;    \/\/ 0x10    volatile uint32_t EGR;   \/\/ 0x14    volatile uint32_t CCMR1; \/\/ 0x18    volatile uint32_t CCMR2; \/\/ 0x1C    volatile uint32_t CCER;  \/\/ 0x20    volatile uint32_t CNT;   \/\/ 0x24    volatile uint32_t PSC;   \/\/ 0x28    volatile uint32_t ARR;   \/\/ 0x2C    volatile uint32_t RCR;   \/\/ 0x30    volatile uint32_t CCR1;  \/\/ 0x34    volatile uint32_t CCR2;  \/\/ 0x38    volatile uint32_t CCR3;  \/\/ 0x3C    volatile uint32_t CCR4;  \/\/ 0x40    volatile uint32_t BDTR;  \/\/ 0x44    volatile uint32_t DCR;   \/\/ 0x48    volatile uint32_t DMAR;  \/\/ 0x4C} TIM_TypeDef;#define TIM2 ((TIM_TypeDef*)0x40000000)#endif<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <code>TIM2<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u201c\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u201d C, \u0430 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043b\u043e\u043a\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043f\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0430 <code>TIM2-&gt;PSC = 7999;<\/code> \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439.<\/p>\n<h3>inc\/config.h<\/h3>\n<pre><code class=\"cpp\">#ifndef CONFIG_H#define CONFIG_H#include \"GPIO.h\"#include \"Timers.h\"void MCU_init(void);#endif<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>inc\/main.h<\/h3>\n<pre><code class=\"cpp\">#ifndef MAIN_H#define MAIN_H#include \"config.h\"#include \"LED.h\"#endif<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u0415\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438: MCU_init()<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0441\u0442\u0451\u0442, \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <code>MCU_init()<\/code>.<\/p>\n<pre><code class=\"cpp\">#include \"config.h\"void MCU_init(void){    GPIO_init();    TIMERS_init();}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 <code>main()<\/code> \u043a\u043e\u0440\u043e\u0447\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435: \u0432 \u043d\u0451\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u0430 \u0434\u0435\u0442\u0430\u043b\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GPIOC \u0438 \u043d\u043e\u0436\u043a\u0438 PC13<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430 GPIOC \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 PC13.<\/p>\n<h3>\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 clock \u0434\u043b\u044f GPIOC<\/h3>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 <code>RCC_APB2ENR<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>0x40021018<\/code>. \u0411\u0438\u0442 4 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 GPIOC.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u043e\u0440\u0442\u0430 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u043d\u043e \u0441\u0430\u043c\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 PC13<\/h3>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 <code>GPIOC_CRH<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>0x40011004<\/code>. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043d\u043e\u0436\u043a\u0438 \u0441 8-\u0439 \u043f\u043e 15-\u044e.<\/p>\n<p>\u0414\u043b\u044f PC13 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b <code>[23:20]<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0438 \u043e\u0447\u0438\u0449\u0430\u044e\u0442\u0441\u044f, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><code>MODE = 10<\/code> \u2014 \u0432\u044b\u0445\u043e\u0434 2 \u041c\u0413\u0446;<\/p>\n<\/li>\n<li>\n<p><code>CNF = 00<\/code> \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 push-pull output.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 GPIO.c<\/h3>\n<pre><code class=\"cpp\">#include \"GPIO.h\"void GPIO_init(void){    \/\/\u0411\u0438\u0442 4-\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 RCC_APB2ENR \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443    *(volatile uint32_t*)0x40021018 |= (1 &lt;&lt; 4);    \/\/\u041e\u0447\u0438\u0449\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432 [23:20] \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 GPIOC_CRH    *(volatile uint32_t*)0x40011004 &amp;= ~(0b1111 &lt;&lt; 20);      \/\/\u0417\u0430\u043f\u0438\u0441\u044c \u0431\u0438\u0442\u043e\u0432 [23:20] \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430   GPIOC_CRH    *(volatile uint32_t*)0x40011004 |=  (0b0010 &lt;&lt; 20);  }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c<\/h2>\n<p>\u041d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0430\u0445 \u0441 STM32F103C8T6 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u043d\u0430 PC13 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u043f\u043e \u0441\u0445\u0435\u043c\u0435 active-low.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>0<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u2014 <code>1<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u201c\u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442\u201d, \u043d\u043e \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u044b \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e.<\/p>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 LED.c<\/h3>\n<pre><code class=\"cpp\">#include \"LED.h\"void turnOnLED(void){    *(volatile uint32_t*)0x4001100C &amp;= ~(1 &lt;&lt; 13);}void turnOffLED(void){    *(volatile uint32_t*)0x4001100C |= (1 &lt;&lt; 13);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410\u0434\u0440\u0435\u0441 <code>0x4001100C<\/code> \u2014 \u044d\u0442\u043e <code>GPIOC_ODR<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<h2>\u0422\u0430\u0439\u043c\u0435\u0440 TIM2<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0442\u0430\u0439\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430: \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0447\u0451\u0442\u0430 \u0438 \u0436\u0434\u0451\u043c \u0444\u043b\u0430\u0433 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0421\u043c\u044b\u0441\u043b<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">TIM<\/p>\n<\/td>\n<td>\n<p align=\"left\">Timer<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">PSC<\/p>\n<\/td>\n<td>\n<p align=\"left\">Prescaler<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ARR<\/p>\n<\/td>\n<td>\n<p align=\"left\">Auto-Reload Register<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CR1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Control Register 1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">SR<\/p>\n<\/td>\n<td>\n<p align=\"left\">Status Register<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">UIF<\/p>\n<\/td>\n<td>\n<p align=\"left\">Update Interrupt Flag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0444\u043b\u0430\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0427\u0430\u0441\u0442\u043e\u0442\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430 STM32F103 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 HSI \u043d\u0430 8 \u041c\u0413\u0446.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 clock tree \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><code>HCLK = 8 MHz<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>PCLK1 = 8 MHz<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>TIM2CLK = 8 MHz<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430<\/h3>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<pre><code class=\"cpp\">TIM2-&gt;PSC = 7999;TIM2-&gt;ARR = 999;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">f_counter = f_tim \/ (PSC + 1)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">f_counter = 8 000 000 \/ (7999 + 1) = 1000 Hz<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0442\u0438\u043a \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0434\u043b\u0438\u0442\u0441\u044f 1 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 <code>ARR = 999<\/code> \u0434\u0430\u0451\u0442 1000 \u0442\u0438\u043a\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u043e\u0432\u043d\u043e 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<h3>\u0412\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 clock \u0434\u043b\u044f TIM2<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0442\u0430\u0439\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0430\u043b \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>RCC_APB1ENR<\/code>, \u0431\u0438\u0442 <code>TIM2EN<\/code>.<\/p>\n<p>\u0410\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430: 0x4002101C<\/p>\n<p>\u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 <code>UIF<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<p>\u0411\u0438\u0442 TIM2-&gt;SR \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u043e\u043b\u044c \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0442\u0430\u0439\u043c\u0435\u0440\u0430 &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430.<\/p>\n<h3>\u041f\u043e\u043b\u043d\u044b\u0439 Timers.c<\/h3>\n<pre><code class=\"cpp\">#include \"Timers.h\"static void TIM2_init(void);void TIMERS_init(void){    TIM2_init();}static void TIM2_init(void){    \/\/\u0421\u0442\u0430\u0432\u0438\u043c \u0435\u0434\u0438\u043d\u0438\u0447\u043a\u0443 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 RCC_APB1ENR \u0432 \u0431\u0438\u0442 TIM2EN    *(volatile uint32_t*)0x4002101C |= (1 &lt;&lt; 0);    TIM2-&gt;SR  &amp;= ~(1 &lt;&lt; 0);    TIM2-&gt;PSC  = 7999;    TIM2-&gt;ARR  = 999;    TIM2-&gt;CR1 |= (1 &lt;&lt; 0);}void delayOneSecond(void){    \/\/\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e TIM2-&gt;SR \u0431\u0438\u0442 UIF = 1, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u043e\u0448\u043b\u0430 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430    while ((TIM2-&gt;SR &amp; (1 &lt;&lt; 0)) == 0){}    \/\/\u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c Status Register, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f    TIM2-&gt;SR &amp;= ~(1 &lt;&lt; 0); }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 delayOneSecond()<\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u043e\u043f\u0440\u043e\u0441\u0435 \u0444\u043b\u0430\u0433\u0430 <code>UIF<\/code>.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u0434 \u0436\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 \u0431\u0438\u0442 <code>UIF<\/code> \u0432 <code>SR<\/code> \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 1. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0444\u043b\u0430\u0433 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u042d\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430: \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u0439\u043c\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u0431\u0438\u0442\u0435 <code>UIF<\/code> \u0435\u0434\u0438\u043d\u0438\u0446\u0430, \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0441\u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0430\u0439\u043b main.c<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0436\u0435 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, <code>main()<\/code> \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439. \u0418 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a: \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443, \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0448\u0443\u043c\u0430.<\/p>\n<pre><code class=\"cpp\">#include \"main.h\"int main(void){    MCU_init();    while (1){        turnOnLED();        delayOneSecond();        turnOffLED();        delayOneSecond();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<h2>\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f firmware.elf \u0438 firmware.bin<\/h2>\n<p>\u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 ELF-\u0444\u0430\u0439\u043b, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432 \u043f\u043b\u043e\u0441\u043a\u0438\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<h3>firmware.elf<\/h3>\n<p>ELF (<code>Executable and Linkable Format<\/code>) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043d\u043e \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u043a\u0446\u0438\u044f\u0445, \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u0445 \u0438 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>firmware.bin<\/h3>\n<p>BIN \u2014 \u044d\u0442\u043e \u0443\u0436\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0431\u0435\u0437 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0448\u0438\u0432\u0430\u044e\u0442 \u0432\u043e FLASH \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<pre><code class=\"bash\">arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -nostdlib -Iinc \\-T myLinker.ld startup\/startup.c src\/main.c src\/config.c src\/GPIO.c \\src\/LED.c src\/Timers.c -o firmware.elfarm-none-eabi-objcopy -O binary firmware.elf firmware.bin<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043b\u0438\u043d\u043a\u0435\u0440 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 <code>firmware.elf<\/code>, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f <code>startup.c<\/code> \u0438 <code>myLinker.ld<\/code>. \u0417\u0430\u0442\u0435\u043c <code>objcopy<\/code> \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u0437 ELF \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<h2>\u0421\u043b\u043e\u0432\u0430\u0440\u044c \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440<\/h2>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0410\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">MCU<\/p>\n<\/td>\n<td>\n<p align=\"left\">Microcontroller Unit<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0441\u0430\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">RCC<\/p>\n<\/td>\n<td>\n<p align=\"left\">Reset and Clock Control<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0431\u043b\u043e\u043a \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0431\u0440\u043e\u0441\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">GPIO<\/p>\n<\/td>\n<td>\n<p align=\"left\">General Purpose Input\/Output<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043d\u043e\u0436\u043a\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ODR<\/p>\n<\/td>\n<td>\n<p align=\"left\">Output Data Register<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">TIM<\/p>\n<\/td>\n<td>\n<p align=\"left\">Timer<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">PSC<\/p>\n<\/td>\n<td>\n<p align=\"left\">Prescaler<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ARR<\/p>\n<\/td>\n<td>\n<p align=\"left\">Auto-Reload Register<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0447\u0451\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CR1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Control Register 1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">SR<\/p>\n<\/td>\n<td>\n<p align=\"left\">Status Register<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0444\u043b\u0430\u0433\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">UIF<\/p>\n<\/td>\n<td>\n<p align=\"left\">Update Interrupt Flag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0444\u043b\u0430\u0433 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">APB<\/p>\n<\/td>\n<td>\n<p align=\"left\">Advanced Peripheral Bus<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0448\u0438\u043d\u0430 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">PCLK1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Peripheral Clock 1<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 APB1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">HSI<\/p>\n<\/td>\n<td>\n<p align=\"left\">High Speed Internal<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 RC-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 8 \u041c\u0413\u0446<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">FLASH<\/p>\n<\/td>\n<td>\n<p align=\"left\">Flash memory<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">RAM<\/p>\n<\/td>\n<td>\n<p align=\"left\">Random Access Memory<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ELF<\/p>\n<\/td>\n<td>\n<p align=\"left\">Executable and Linkable Format<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0444\u0430\u0439\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u041f\u043e\u043b\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0412\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 GitHub: <a href=\"https:\/\/github.com\/dimchickka\/codeForSTM32_fromScrath\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/dimchickka\/codeForSTM32_fromScrath<\/a><\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0451\u043c \u0432\u0438\u0434\u043d\u043e \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430: \u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 linker script \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b GPIO \u0438 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u0422\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u201c\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u201d, \u0430 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e <code>main()<\/code>.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1022976\/\">https:\/\/habr.com\/ru\/articles\/1022976\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0438\u0442\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0441\u0431\u0440\u043e\u0441\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u0432\u0445\u043e\u0434\u0430 \u0432 main(). \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f\u0434\u0440\u043e Cortex-M3 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u0431\u0440\u043e\u0441\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 startup-\u043a\u043e\u0434.\u0412 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c bare-metal \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0431\u0435\u0437 HAL \u0438 \u0431\u0435\u0437 CubeMX \u0432\u0441\u044f \u044d\u0442\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e \u0448\u0430\u0433\u0430\u043c. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441\u043e STM32: \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438\u043d\u043a\u0435\u0440, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d startup \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 C-\u043a\u043e\u0434 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u201c\u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435\u201d.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043d\u0443\u043b\u044f:\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 linker script;startup-\u0444\u0430\u0439\u043b;\u0440\u0443\u0447\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f .data \u0438 .bss;\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GPIO;\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c \u043d\u0430 PC13;\u0437\u0430\u043f\u0443\u0441\u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 TIM2.\u0426\u0435\u043b\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u0433\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434. \u0426\u0435\u043b\u044c \u2014 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0438 \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434. \u0421\u0442\u0430\u0442\u044c\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e \u0446\u0435\u043d\u0435 \u0447\u0430\u0448\u043a\u0438 \u043a\u043e\u0444\u0435 STM32F103C8T6.  \u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u0435\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u043d\u0430 PC13;\u0436\u0434\u0430\u0442\u044c 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443;\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434;\u0441\u043d\u043e\u0432\u0430 \u0436\u0434\u0430\u0442\u044c 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0421\u0440\u0430\u0437\u0443 \u0443\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0451\u0432:full_program_from_scratch\/\u251c\u2500\u2500 inc\/\u2502   \u251c\u2500\u2500 config.h\u2502   \u251c\u2500\u2500 GPIO.h\u2502   \u251c\u2500\u2500 LED.h\u2502   \u251c\u2500\u2500 main.h\u2502   \u2514\u2500\u2500 Timers.h\u251c\u2500\u2500 src\/\u2502   \u251c\u2500\u2500 config.c\u2502   \u251c\u2500\u2500 GPIO.c\u2502   \u251c\u2500\u2500 LED.c\u2502   \u251c\u2500\u2500 main.c\u2502   \u2514\u2500\u2500 Timers.c\u251c\u2500\u2500 startup\/\u2502   \u2514\u2500\u2500 startup.c\u251c\u2500\u2500 myLinker.ld\u251c\u2500\u2500 firmware.elf\u2514\u2500\u2500 firmware.bin\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0438\u0434\u0435\u044f bare-metal \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u0412 bare-metal-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0435\u0439 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043f\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0438\u0434 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:*(volatile uint32_t*)0x40021018 |= (1 &lt;&lt; 4);\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.volatile\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e volatile \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u201c\u0443\u043c\u043d\u044b\u0435\u201d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e, \u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u0438 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0435\u043c\u0443 \u0432\u044b\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u0442\u0430\u0440\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e, \u0432\u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f.uint32_t\u0420\u0435\u0433\u0438\u0441\u0442\u0440 STM32F1 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 32 \u0431\u0438\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e uint32_t.0x40021018\u042d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 RCC_APB2ENR. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0438 \u043d\u0430 \u0448\u0438\u043d\u0435 APB2.(1 &lt;&lt; 4)\u0411\u0438\u0442 4 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0440\u0442\u0443 GPIOC. \u041f\u043e\u043a\u0430 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044f GPIOC \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 clock \u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.\u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u0440\u0443\u0431\u043e\u0432\u0430\u0442\u043e, \u0437\u0430\u0442\u043e \u043e\u043d \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f: \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u201c\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u201d, \u0430 \u043c\u0435\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0431\u0438\u0442 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.\u041f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e\u0442 \u0441\u0442\u0438\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0414\u043b\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 TIM2 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e: \u0432\u043c\u0435\u0441\u0442\u043e \u0433\u043e\u043b\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c TIM2.Linker script: \u043a\u0430\u0440\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430Linker script \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043b\u0438\u043d\u043a\u0435\u0440\u0443, \u0433\u0434\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0435\u0436\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 .text, .data, .bss, .isr_vector \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e STM32.\u0423 linker script \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0438:\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438;\u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e \u044d\u0442\u0438\u043c \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c;\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0434\u043b\u044f startup-\u043a\u043e\u0434\u0430;\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430.\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043b\u0438\u043d\u043a\u0435\u0440 \u0444\u0430\u0439\u043b:_estack = = ORIGIN(RAM) + LENGTH(RAM);MEMORY{    FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x00010000    RAM   (rwx): ORIGIN = 0x20000000, LENGTH = 0x00005000}SECTIONS{    .isr_vector :    {        KEEP(*(.isr_vector))    } &gt; FLASH    .text :    {        *(.text)        *(.text*)    } &gt; FLASH    .rodata :    {        *(.rodata)        *(.rodata*)    } &gt; FLASH    .data :    {        _sdata = .;  \/\/\u0422\u043e\u0447\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0432 RAM        *(.data)        *(.data*)        _edata = .;    } &gt; RAM AT &gt; FLASH    _sidata = LOADADDR(.data); \/\/\u0422\u043e\u0447\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e FLASH \u043f\u0430\u043c\u044f\u0442\u0438    .bss :    {        _sbss = .;        *(.bss)        *(.bss*)        _ebss = .;    } &gt; RAM}\u041e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438\u0414\u043b\u044f STM32F103C8T6 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438:\u041e\u0431\u043b\u0430\u0441\u0442\u044c\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0434\u0440\u0435\u0441\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435FLASH0x08000000\u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430RAM0x20000000\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0441\u0442\u0435\u043a, .data, .bss\u0412 \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0441\u0442\u0435\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b:_estack = ORIGIN(RAM) + LENGTH(RAM);\u041e\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 RAM \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Cortex-M3 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 SP \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.\u0421\u0435\u043a\u0446\u0438\u0438.isr_vector\u0417\u0434\u0435\u0441\u044c \u043b\u0435\u0436\u0438\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f KEEP(&#8230;)..text\u0421\u0435\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432\u043e FLASH..rodata\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e\u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u043e FLASH..data\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 RAM, \u043d\u043e \u0438\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u043e FLASH, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0441\u0435\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a &gt; RAM AT &gt; FLASH..bss\u041d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043e\u043d\u0438 \u0437\u0430\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e.\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b sidata, sdata, edata, sbss, _ebss\u042d\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u043d\u043a\u0435\u0440, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 startup-\u043a\u043e\u0434._sidata \u2014 \u0430\u0434\u0440\u0435\u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e FLASH;_sdata \u2014 \u043d\u0430\u0447\u0430\u043b\u043e .data \u0432 RAM;_edata \u2014 \u043a\u043e\u043d\u0435\u0446 .data \u0432 RAM;_sbss \u2014 \u043d\u0430\u0447\u0430\u043b\u043e .bss;_ebss \u2014 \u043a\u043e\u043d\u0435\u0446 .bss.\u0411\u0435\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u043a startup-\u043a\u043e\u0434 \u043d\u0435 \u0441\u043c\u043e\u0433 \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043d\u0443\u043b\u044f\u0442\u044c.\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c*(.data) : \u042d\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u0441\u0435\u043a\u0446\u0438\u0439 \u0441 \u0442\u043e\u0447\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c .data. \u0421\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.  *(.data*) : \u0417\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043b\u044e\u0431\u043e\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u00bb.    \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430: main.c \u0438 sensor.c.   \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0437 \u043d\u0438\u0445 main.o \u0438 sensor.o. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u043a\u043e\u0440\u043e\u0431\u043e\u0447\u043a\u0430 \u0441 \u043d\u0430\u0434\u043f\u0438\u0441\u044c\u044e .data.   \u041b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a \u0432\u0438\u0434\u0438\u0442 \u0432\u0430\u0448\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e *(.data).   \u041e\u043d \u0438\u0434\u0435\u0442 \u0432 main.o, \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0442\u0442\u0443\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 .data, \u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u0442 \u0432 sensor.o, \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0442\u0443\u0434\u0430 \u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0434\u043d\u0443 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e .data \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.  \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 .data \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e .o \u0444\u0430\u0439\u043b\u0430. \u042d\u0442\u0430 \u0441\u0435\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f .data.a. \u0422\u043e\u0433\u0434\u0430, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e *(.data),\u043b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c *(.data*).Startup-\u0444\u0430\u0439\u043b: \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430Startup-\u043a\u043e\u0434 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0430\u0447\u0438 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0441\u0431\u0440\u043e\u0441\u0430. \u0414\u043e \u0432\u044b\u0437\u043e\u0432\u0430 main() \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.\u041b\u0438\u043d\u043a\u0435\u0440\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b\u0412 startup-\u0444\u0430\u0439\u043b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:extern uint32_t _estack;extern uint32_t _sidata;extern uint32_t _sdata;extern uint32_t _edata;extern uint32_t _sbss;extern uint32_t _ebss;\u042d\u0442\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435. \u042d\u0442\u043e \u0430\u0434\u0440\u0435\u0441\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u043d\u043a\u0435\u0440\u043e\u043c. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 C-\u043a\u043e\u0434\u0443 \u043f\u043e\u043d\u044f\u0442\u044c, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.\u0412\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0412\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0438\u0449\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437 \u043d\u0443\u0436\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\u0412 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c Reset_Handler, NMI_Handler \u0438 HardFault_Handler. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 Default_Handler.weak alias\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f attribute((weak, alias(&#171;Default_Handler&#187;))) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442: \u0435\u0441\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Default_Handler.\u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u0440\u0430\u0437\u0443 \u2014 \u043d\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0439\u0434\u0443\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.Reset_Handler\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 Reset_Handler. \u0412 \u043d\u0451\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:\u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c .data \u0438\u0437 FLASH \u0432 RAM;\u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c .bss. \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c main().\u0417\u0434\u0435\u0441\u044c main() \u0438 \u0435\u0441\u0442\u044c \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u043e \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0435 \u0432 \u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430.\u041f\u043e\u043b\u043d\u044b\u0439 startup.c#include &lt;stdint.h&gt;extern uint32_t _estack;extern uint32_t _sidata;extern uint32_t _sdata;extern uint32_t _edata;extern uint32_t _sbss;extern uint32_t _ebss;int main(void);void Reset_Handler(void);void Default_Handler(void);void NMI_Handler(void)       __attribute__((weak, alias(&#171;Default_Handler&#187;)));void HardFault_Handler(void)  __attribute__((weak, alias(&#171;Default_Handler&#187;)));__attribute__((used, section(&#171;.isr_vector&#187;)))const void* vector_table[] ={    &amp;_estack,    Reset_Handler,    NMI_Handler,    HardFault_Handler};void Reset_Handler(void){    uint32_t* src = &amp;_sidata; \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e FLASH    uint32_t* dst = &amp;_sdata;  \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 RAM    while (dst &lt; &amp;_edata){        *dst++ = *src++;      \/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 FLASH \u0432 RAM    }    dst = &amp;_sbss;    while (dst &lt; &amp;_ebss){  \/\/ \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0435\u043a\u0446\u0438\u0438 .bss \u0432 RAM        *dst++ = 0;        \/\/\u0417\u0430\u043d\u0443\u043b\u044f\u0435\u043c \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435    }    main();    while (1){    }}void Default_Handler(void){    while (1){    }}\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b: \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439\u0412 inc\/ \u043b\u0435\u0436\u0430\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0418\u0445 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043e\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u043c \u0447\u0430\u0441\u0442\u044f\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430.\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041e\u0434\u0438\u043d .c-\u0444\u0430\u0439\u043b \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u201c\u0437\u043d\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0433\u043e\u201d \u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e .c-\u0444\u0430\u0439\u043b\u0430, \u0435\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b.\u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0438\u0442\u0430\u043d\u0438\u044f CPU \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0432 \u0430\u0434\u0440\u0435\u0441 0x00000000, \u0431\u0435\u0440\u0451\u0442 \u043e\u0442\u0442\u0443\u0434\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0435\u043a. \u0414\u0430\u043b\u0435\u0435 CPU \u0447\u0438\u0442\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 0x00000004 &#8212; \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 Reset_Handler.\u041f\u043e\u0441\u043b\u0435 CPU \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c ResetHandler() \u0438 \u043e\u0442\u0442\u0443\u0434\u0430 \u0443\u0436\u0435 \u043f\u0440\u044b\u0433\u0430\u0435\u0442 \u0432 main().inc\/GPIO.h#ifndef GPIO_H#define GPIO_H#include &lt;stdint.h&gt;void GPIO_init(void);#endifinc\/LED.h#ifndef LED_H#define LED_H#include &lt;stdint.h&gt;void turnOnLED(void);void turnOffLED(void);#endifinc\/Timers.h\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430.#ifndef TIMERS_H#define TIMERS_H#include &lt;stdint.h&gt;void TIMERS_init(void);void delayOneSecond(void);typedef struct{    volatile uint32_t CR1;   \/\/ 0x00    volatile uint32_t CR2;   \/\/ 0x04    volatile uint32_t &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-475773","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=475773"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475773\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=475773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=475773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=475773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}