{"id":4570,"date":"2015-12-09T22:56:24","date_gmt":"2015-12-09T18:56:24","guid":{"rendered":"http:\/\/avr-start.ru\/?p=4570"},"modified":"2015-12-09T22:56:44","modified_gmt":"2015-12-09T18:56:44","slug":"stm32-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%b0-%d1%81-flash","status":"publish","type":"post","link":"https:\/\/avr-start.ru\/?p=4570","title":{"rendered":"STM32 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 Flash."},"content":{"rendered":"<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c. \u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0442\u0447\u0435\u0442.<br \/>\n<!--more--><\/p>\n<p>\u0418\u0442\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u043f\u0440\u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0438 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0438 \u0438\u0437 \u0434\u0435\u0432\u0430\u0439\u0441\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043f\u0438\u0442\u0430\u043b\u043e\u0432\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0440\u0443\u0431\u0438\u0442\u0441\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0445\u0435\u043c\u044b \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/sch_bat.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/sch_bat.png\" alt=\"sch_bat\" width=\"416\" height=\"198\" class=\"alignnone size-full wp-image-4583\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/sch_bat.png 416w, https:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/sch_bat-300x143.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/a><\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0442\u0430\u0449\u0435\u043d\u0430, \u0410\u0426\u041f \u044d\u0442\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0435 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0430\u0441\u0435 \u043a\u043e\u043d\u0434\u0435\u0440\u0430 C1. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0443 \u043f\u043e\u043c\u0435\u043d\u044f\u044e\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0441 \u0442\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u0412 \u043e\u0431\u0449\u0435\u043c \u043d\u0443\u0436\u043d\u043e, \u0433\u0434\u0435 \u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0432 \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0411\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: EEPROM, Flash, backup \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b. \u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u0434\u0435\u0432\u0430\u0439\u0441\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438\u0441\u044c. \u0415\u0435\u043f\u0440\u043e\u043c, \u043e\u0442\u043c\u0435\u043b\u0430\u0441\u044c, \u0445\u043e\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u043c\u043d\u043e\u0439 \u043a\u0430\u043c\u043d\u0435 STM32L1 \u043e\u043d\u0430 \u0435\u0441\u0442\u044c, \u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0443\u0436\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0438. \u0410 \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0435\u0435\u043f\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u043d\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0438\u044f\u0445 \u0441\u0442\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0442\u043c\u0435\u043b\u0441\u044f \u0441\u0430\u043c \u0441\u043e\u0431\u043e\u0439. Backup \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b, \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439, \u0434\u0430\u0436\u0435 \u043e\u0447\u0435\u043d\u044c, \u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0430. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u0440\u043e\u043c\u0435 \u0444\u043b\u0435\u0448\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c. <\/p>\n<p>\u0418\u0437 \u0438\u043d\u0444\u044b \u043f\u0440\u043e \u0444\u043b\u0435\u0448. \u041f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0431\u0430\u0439\u0442\u0430\u043c\u0438, \u0430 \u0432\u043e\u0442 \u0441\u0442\u0438\u0440\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438, \u0440\u0435\u0441\u0443\u0440\u0441 \u043e\u043a\u043e\u043b\u043e 10000 \u0440\u0430\u0437. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0412\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u0443\u0447\u0448\u0435 \u0431\u043b\u0438\u0436\u0435 \u043a \u043a\u043e\u043d\u0446\u0443 \u0444\u043b\u0435\u0448\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0442\u0435\u0440\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0432\u0437\u044f\u043b \u0430\u0434\u0440\u0435\u0441 0x08030000.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/stm_flash.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/stm_flash.png\" alt=\"stm_flash\" width=\"579\" height=\"477\" class=\"alignnone size-full wp-image-4585\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/stm_flash.png 579w, https:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/stm_flash-300x247.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/a><\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u043b\u043e\u0447\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u0442\u0435\u0440\u0435\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u0437\u0430\u043b\u043e\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e flash.<br \/>\n\u0421 SPL \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<pre lang=\"c\">\r\nFLASH_Unlock();\r\nFLASH_ErasePage(0x8030000); \/\/\u0441\u0442\u0438\u0440\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443\r\nFLASH_FastProgramWord(0x8030000, 0xEFDC9988); \/\/\u043f\u0438\u0448\u0435\u043c 4 \u0431\u0430\u0439\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x8030000\r\n\t\r\nFLASH_Lock();\r\n<\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435, \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u043e\u0440\u043c \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c memory, \u043d\u043e \u043f\u043e\u0436\u0430\u043b\u0443\u0439 \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043d\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438, \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0441\u0447\u0435\u0442\u043d\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 flash, \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0442\u0438\u043a\u0430\u043b\u043e. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043e \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043c\u0438\u0433\u0430\u043d\u0438\u044f \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c.  <\/p>\n<pre lang=\"c\">\r\nwhile(1)\r\n{\t\r\n \/\/\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c\r\n  for(uint16_t i = 0; i < 65000; i++);  \r\n  GPIO_ToggleBits(GPIOB, GPIO_Pin_7);\r\n}\r\n<\/pre>\n<p>\u041e\u0441\u0446\u0438\u043b\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043d\u043e\u0433\u043e\u0434\u0440\u044b\u0433\u0430 15.3\u0413\u0446,<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/freq_operation.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2015\/12\/freq_operation.png\" alt=\"freq_operation\" width=\"600\" height=\"380\" class=\"alignnone size-full wp-image-4572\" \/><\/a><\/p>\n<p>\u0442.\u0435 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u0446\u0438\u043a\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 1\/(15.3*2) = 0.032\u0441\u0435\u043a. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435.<\/p>\n<p>\u0417\u0430\u0432\u043e\u0434\u0438\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e TIM7. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u0432\u0437\u044f\u0442\u043e \u043e\u0442 \u0431\u0430\u043b\u0434\u044b.<\/p>\n<pre lang=\"c\">\r\n\/\/ FREQ = F_CPU\/(PRESC) * PERIOD\r\nTIM_TimeBaseInitTypeDef       tim_setup7;\r\ntim_setup7.TIM_ClockDivision   = TIM_CKD_DIV1; \/\/\u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b\r\ntim_setup7.TIM_CounterMode     = TIM_CounterMode_Up; \/\/\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0432\u0432\u0435\u0440\u0445\r\ntim_setup7.TIM_Period          = 2000-1; \/\/\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e 2000, \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u043d\u0443\u043b\u0438\u0442\u044c\r\ntim_setup7.TIM_Prescaler       = 16000; \/\/\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c 16000\r\n\t\t\r\nTIM_TimeBaseInit(TIM7, &tim_setup7);\r\n\/\/TIM_Cmd(TIM7, ENABLE);\r\n\t\r\nTIM_ITConfig(TIM7, TIM_IT_Update, ENABLE); \/\/\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e\r\nNVIC_EnableIRQ(TIM7_IRQn); \/\/\u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430\r\n<\/pre>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435, \u0442\u0430\u043c \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c - \u0434\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c. \u041e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0442\u0438\u043a\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<pre lang=\"c\">\r\nwhile(1)\r\n{\r\n  TIM_Cmd(TIM7, ENABLE);    \/\/\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440\r\n  TIM7->CNT = 0;            \/\/\u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0441\u0447\u0435\u0442\u043d\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\r\n  COUNTS = 0;               \/\/\u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e\r\n\t\r\n  for(uint16_t i = 0; i < 65000; i++);  \/\/\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c\r\n  GPIO_ToggleBits(GPIOB, GPIO_Pin_7);\r\n\t\t\r\n  TIM_Cmd(TIM7, DISABLE);   \/\/\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0438\u043a\u0430\u043b\r\n  COUNTS = TIM7->CNT;       \/\/\u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043a\u043e\u0432 \r\n}\r\n<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a, \u0441\u0442\u0430\u0432\u0438\u043c 3 \u0431\u0440\u044f\u043a\u0438: 1. \u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430; 2. \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f; 3. \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0443, \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0431\u0440\u044f\u043a\u0438, \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u043c \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0442\u0438\u043a\u0430\u043b\u043e. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0448\u043b\u043e 0x20 \u0438\u043b\u0438 32. \u0422\u0430\u0439\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 F_CPU\/\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c = 16 000 000\/16 000 = 1 \u043a\u0413\u0446, \u0442.\u0435. 1 \u0442\u0438\u043a 0.001\u0441\u0435\u043a. \u0418\u0442\u043e\u0433\u043e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0443\u043f\u043d\u044f\u043a\u0430 \u0441 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0436\u043a\u0438 \u0437\u0430\u043d\u044f\u043b\u0430 0.001*32 = 0.0032 \u0441\u0435\u043a \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u043d\u044b\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430\u043c. \u042d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c\u0438 \u043e\u0441\u0446\u0438\u043b\u043b\u0430.<\/p>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0431\u044b\u043b \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d \u043d\u0430\u0443\u0433\u0430\u0434 \u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0438 \u0443\u0434\u0430\u0447\u043d\u043e. \u0412\u043d\u0443\u0442\u0440\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u044f \u043d\u0435 \u043f\u043e\u043f\u0430\u043b, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e, \u043d\u043e \u0432\u0441\u0435 \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u0443\u0434\u0430\u0447\u043d\u043e. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u043f\u043e\u043f\u0430\u043b \u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u0438\u0431\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u043b\u0438\u0431\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u0438\u043b\u0430\u0441\u044c \u0431\u044b \u0438\u043d\u0430\u0447\u0435 \u0438 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430\u0442\u0438\u043a\u0430\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e, \u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u044b\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d \u0437\u0430\u043c\u0435\u0440 \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 4 \u0431\u0430\u0439\u0442 \u0432\u043e \u0444\u043b\u0435\u0448. \u0421 \u0442\u0435\u043c \u0436\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u043c \u0438 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u0443 \u043c\u0435\u043d\u044f \u043d\u0430\u0442\u0438\u043a\u0430\u043b\u043e 5\u043c\u0441.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c. \u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0442\u0447\u0435\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[142,81],"class_list":["post-4570","post","type-post","status-publish","format-standard","hentry","category-stm","tag-flash","tag-stm32"],"_links":{"self":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/4570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4570"}],"version-history":[{"count":20,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/4570\/revisions"}],"predecessor-version":[{"id":4594,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/4570\/revisions\/4594"}],"wp:attachment":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}