{"id":358726,"date":"2024-05-21T00:17:49","date_gmt":"2024-05-21T00:17:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358726"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358726","title":{"rendered":"<span>\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0430 STM32<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 STM32. <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0436\u0435\u043b\u0435\u0437\u043e\u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0438\u0437\u043c\u0435\u0440\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. \u041e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043d\u0435\u0433\u043e\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c \u043f\u044b\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0432\u043e\u0440\u043a\u0430\u0445 \u0434\u0438\u0441\u043a\u0430 D \u0438 \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443-\u0442\u043e, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0441\u044f \u0432 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/9c5\/d1a\/9b9\/9c5d1a9b9996e1a52530fe4d83e9477e.jpg\" alt=\"\u041d\u0430\u0448 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0441\u0442\u0435\u043d\u0434: \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b JDS6600 \u0438 BluePill\" title=\"\u041d\u0430\u0448 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0441\u0442\u0435\u043d\u0434: \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b JDS6600 \u0438 BluePill\" width=\"2116\" height=\"3236\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c5\/d1a\/9b9\/9c5d1a9b9996e1a52530fe4d83e9477e.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0448 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0441\u0442\u0435\u043d\u0434: \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b JDS6600 \u0438 BluePill<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043e\u0442 0 \u0434\u043e 10 \u043a\u0413\u0446. \u041c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 STM32F103C8T6, \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0430 bluepill. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 HAL. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u0432\u0443\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b <a href=\"https:\/\/supereyes.ru\/catalog\/waveform_generator\/generator_signalov_junce_jds6600_60m_2_kanala_kh_60_mgts\/\" rel=\"noopener noreferrer nofollow\">JDS6600<\/a>. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c CH340G (\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c USB &#8212; UART) \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (terminal v1.9b) \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438. \u0412 \u043d\u0435\u0433\u043e \u044f \u0431\u0443\u0434\u0443 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2013 <strong>\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/strong><\/p>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u0432\u044b\u0432\u043e\u0434\u0430\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <strong>PA0<\/strong> \u0438 <strong>PA2<\/strong>. \u0412\u044b\u0432\u043e\u0434\u044b \u0437\u0435\u043c\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b.<\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/strong> \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 STM32IDE \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434 \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c UART \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/261\/54e\/5ec\/26154e5ec3ad2a7e20eb2344a98dec9c.jpg\" alt=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UART\" title=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UART\" width=\"801\" height=\"901\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/261\/54e\/5ec\/26154e5ec3ad2a7e20eb2344a98dec9c.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UART<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0430\u0441\u0442\u043e\u0442\u0443 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u043d\u0430 64 \u041c\u0413\u0446.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eb6\/c0c\/80b\/eb6c0c80bd8764560706ee494f5a98e4.JPG\" width=\"1868\" height=\"892\"\/><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Timer 2. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0443\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b73\/707\/afa\/b73707afa6df77b2c4c53ec7d14f4232.jpg\" width=\"1850\" height=\"898\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b73\/707\/afa\/b73707afa6df77b2c4c53ec7d14f4232.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041a\u0430\u043d\u0430\u043b 1 \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 (direct) \u043a\u0430\u043d\u0430\u043b, \u0430 \u043a\u0430\u043d\u0430\u043b 2 \u044d\u0442\u043e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 (indirect). \u041a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u0430 3 \u0438 4. \u0417\u0430\u0445\u0432\u0430\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u043e\u043d\u0442, \u0438 \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430. \u041f\u043e\u0441\u043b\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0434\u043d\u0438\u0439 \u0444\u0440\u043e\u043d\u0442, \u0438 \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \/ \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e. \u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0442\u0440\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u0441\u043a\u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 Timer 2: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/419\/683\/942\/4196839429c66586c0a9cc540f3fad5f.jpg\" width=\"588\" height=\"768\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/419\/683\/942\/4196839429c66586c0a9cc540f3fad5f.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0448\u0430\u0433, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u0433, \u0442\u0435\u043c \u0442\u043e\u0447\u043d\u0435\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u041f\u0440\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 64 \u041c\u0413\u0446 \u0438 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435 = 64 (\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 1 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043a\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0440\u0430\u0432\u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0435. \u041f\u0435\u0440\u0438\u043e\u0434 (Counter periode) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0434\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440 \u0434\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043b\u0443\u0447\u0448\u0435 \u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (Input Filter) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u0445 \u0438 \u0448\u0443\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043c\u0435\u0445\u0438. \u0415\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u043d\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d \u0441\u0438\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043c\u0435\u0445\u0430\u043c, \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0448\u0443\u043c\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430\u043c\u0438, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u042f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e Input Filter \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c. \u0412\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ffb\/295\/21f\/ffb29521f66f9f7edbaec60cc1dcc0f3.jpg\" width=\"612\" height=\"194\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ffb\/295\/21f\/ffb29521f66f9f7edbaec60cc1dcc0f3.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><strong>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434:<\/strong> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">volatile uint16_t start1 = 0, end_imp1 = 0, end_per1 = 0, start2 = 0, end_imp2 = 0, end_per2 = 0;<\/code><\/pre>\n<p>\u0433\u0434\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 start \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430, end_imp \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430, end_ per \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430. 1 \u0438 2 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e CH1+CH2 \u0438 CH3+CH4.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/466\/953\/58b\/46695358b850b1f8b9d1b2d163063c10.jpg\" alt=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f.\" title=\"\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f.\" width=\"1146\" height=\"683\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/466\/953\/58b\/46695358b850b1f8b9d1b2d163063c10.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f.<\/figcaption><\/div>\n<\/figure>\n<pre><code class=\"cpp\">volatile uint16_t period1 = 0, fill_factor1 = 0, long_imp1 = 0, period2 = 0, fill_factor2 = 0, long_imp2 = 0; volatile uint16_t freq1 = 0, freq2 = 0; volatile uint8_t flag_IC = 0; <\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u043b\u0430\u0433 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0441\u0438\u0433\u043d\u0430\u043b. \u0414\u0430\u043b\u0435\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u0435 \u043a\u0430\u043d\u0430\u043b\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e UART:<\/p>\n<pre><code class=\"cpp\">  \/* USER CODE BEGIN 2 *\/ HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_1); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_2); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_3); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_4);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 callback (\u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\/\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f) \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN 4 *\/ \/*----------------------------------------------------------------------------*\/ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { if (htim->Instance == TIM2) { if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) { start1 = end_per1; end_per1 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_1); end_imp1 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_2); } if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) { start2 = end_per2; end_per2 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_3); end_imp2 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_4); } flag_IC = 1; } }<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u0439 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 \u00abflag_IC\u00bb, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u0445\u043e\u0434 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">\/*----------------------------------------------------------------------------*\/ void CALC_FREQ (void) { \/\/ \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u0445 (1 \u0438\u043c\u043f\u0443\u043b\u044c\u0441 = 1 \u043c\u043a\u0441) if (end_per1 > start1)  { period1 = end_per1 - start1; long_imp1 = end_imp1 - start1; if (period1 > 0) { freq1 = 1000000 \/ period1; fill_factor1 = (long_imp1 * 100) \/ period1; } } if (end_per2 > start2) { period2 = end_per2 - start2; long_imp2 = end_imp2 - start2; if (period2 > 0) { freq2 = 1000000 \/ period2; fill_factor2 = (long_imp2 * 100) \/ period2; } } }<\/code><\/pre>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u00abif (end_per1 > start1)\u00bb \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043e\u0431\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u0430 \u043a\u043e\u043d\u0435\u0446 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u043e \u043e\u0431\u0441\u0447\u0451\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0441\u0442\u0430\u043b \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e UART \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430:<\/p>\n<pre><code class=\"cpp\">if(flag_IC == 1) { CALC_FREQ(); snprintf(buff, 80, \"Freq 1 = %d fill_factor 1 = %d  Freq 2 = %d fill_factor 2 = %d\\r\\n\", freq1, fill_factor1, freq2, fill_factor2); HAL_UART_Transmit_IT(&amp;huart1, buff, strlen(buff)); HAL_Delay(500); flag_IC = 0; }<\/code><\/pre>\n<p>\u042f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/57d\/d69\/09b\/57dd6909bfea2fdbed857280851a1e36.jpg\" width=\"2247\" height=\"791\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/57d\/d69\/09b\/57dd6909bfea2fdbed857280851a1e36.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041e\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0432\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 1\u043a\u0413\u0446 \u0438 850 \u0413\u0446. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/30e\/9a2\/858\/30e9a2858494b783ab140e4777d4feaf.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/30e\/9a2\/858\/30e9a2858494b783ab140e4777d4feaf.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 115200 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u043d\u043e \u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u042f \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u043e\u0442 1 \u043a\u0413\u0446 \u0434\u043e 8 \u043a\u0413\u0446 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441 \u0448\u0430\u0433\u043e\u043c \u0432 1 \u043a\u0413\u0446 \u0438 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/3a6\/396\/e37\/3a6396e379e593ed11e5ca230e467e89.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3a6\/396\/e37\/3a6396e379e593ed11e5ca230e467e89.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u044f \u043a\u0440\u0443\u0447\u0443 \u0440\u0443\u0447\u043a\u0443, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c. <\/p>\n<p><strong>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">+<\/p>\n<\/td>\n<td>\n<p align=\"center\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u0441\u043a\u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430.<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u044b, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0442\u0430\u0439\u043c\u0435\u0440\u0443 \u043d\u0430 \u0434\u0432\u0430 \u0432\u0445\u043e\u0434\u0430. \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u043e\u0434 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u043e\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u0437\u0430 1 \u043f\u0435\u0440\u0438\u043e\u0434 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (\u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0435).<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u0430\u0439\u043c\u0435\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u043e 65 \u043c\u0441, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f,   \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 100 \u043c\u0441 (10 \u0413\u0446), \u0442\u043e \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445   \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u0439.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0415\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0440\u043e\u043f\u0430\u043b \u2013 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0435 \u043e\u0431\u043d\u0443\u043b\u0438\u0442\u0441\u044f \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b, \u0438 \u0435\u0441\u043b\u0438   \u043d\u0435\u0442, \u0442\u043e \u043e\u0431\u043d\u0443\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b, \u0438\u043b\u0438 \u0436\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u043b\u0430\u0433 \u043f\u0440\u0438   \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 callback.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b <strong>\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0430 EXTI<\/strong>.<\/p>\n<p>\u0412\u044b\u0432\u043e\u0434\u044b EXTI (External Interrupt) \u0443 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 STM32 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u043e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. EXTI \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u2013 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441, \u043c\u044b \u043f\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432, \u0430 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u043e. \u0422\u0430\u043a \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u0443.<\/p>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: <\/strong>\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u0432\u044b\u0432\u043e\u0434\u0430\u043c PA0 \u0438 PA1.<\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <\/strong>\u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b PA0 \u0438 PA1 \u043a\u0430\u043a \u0432\u044b\u0432\u043e\u0434\u044b EXTI. \u0422\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0443 \u043d\u0438\u0445. \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0444\u0440\u043e\u043d\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d1d\/b61\/75b\/d1db6175b88883a6187dcda8d1d5b163.jpg\" width=\"1721\" height=\"778\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d1d\/b61\/75b\/d1db6175b88883a6187dcda8d1d5b163.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c67\/c21\/f67\/c67c21f67a99a67a4d82c0935dda88ec.jpg\" width=\"1390\" height=\"758\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c67\/c21\/f67\/c67c21f67a99a67a4d82c0935dda88ec.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><strong>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434:<\/strong>  <\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN PV *\/ volatile uint32_t num_imp1 = 0, num_imp2 = 0; uint32_t freq1 = 0, freq2 = 0; volatile uint8_t  flag_timer = 0; <\/code><\/pre>\n<p>\u0417\u0430\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441. \u041a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u043b\u0430\u0433, \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432. \u0412\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c callback \u043f\u043e EXTI \u0432\u044b\u0432\u043e\u0434\u0430\u043c:<\/p>\n<pre><code class=\"cpp\">void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {   if (GPIO_Pin == GPIO_PIN_0)   num_imp1++;   if (GPIO_Pin == GPIO_PIN_1)   num_imp2++; } <\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0443:<\/p>\n<pre><code class=\"cpp\">void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13); flag_timer = 1; freq1 = num_imp1; freq2 = num_imp2; num_imp1 = 0; num_imp2 = 0; }<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0437\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u043e UART:<\/p>\n<pre><code class=\"cpp\">if (flag_timer == 1) { snprintf(buff, 80, \"Freq 1 = %d Freq 2 = %d\\r\\n\", freq1, freq2); HAL_UART_Transmit_IT(&amp;huart1, buff, strlen(buff)); flag_timer = 0; }<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0430\u0434\u0438\u043c 1 \u043a\u0413\u0446 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0438 5 \u043a\u0413\u0446 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/6f4\/77d\/2a2\/6f477d2a2486b3261601972b1c26d413.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6f4\/77d\/2a2\/6f477d2a2486b3261601972b1c26d413.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (\u043a\u0430\u043d\u0430\u043b ch2 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c70\/3a9\/f60\/c703a9f60171c7e9f9958439916d6a79.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c70\/3a9\/f60\/c703a9f60171c7e9f9958439916d6a79.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e <strong>\u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430\u0445 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445<\/strong>:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">+<\/p>\n<\/td>\n<td>\n<p align=\"center\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u043e \u2013 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0437 \u0432   \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0443\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\">\n<p align=\"left\">\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u044e \u043c\u0435\u0442\u043e\u0434 \u2013 <strong>\u0437\u0430\u0445\u0432\u0430\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ETR2<\/strong>. \u041f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 ETR2 (External Trigger Input 2), \u0438 \u0442\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0432\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043c\u0435\u0440\u044f\u0435\u043c\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u043c\u0435\u0440 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u043c\u0435\u0440\u0430 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0438\u0431\u043e\u0440\u0430, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043b-\u0432\u0435 \u0442\u0438\u043a\u043e\u0432 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/p>\n<p>\u0417\u0430\u0432\u043e\u0434\u0438\u043c timer 2, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439. \u041f\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430 \u043d\u0430 ETR2 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f timer 4. \u041a\u043e\u0433\u0434\u0430 \u043d\u0430 timer 2 \u043f\u0440\u0438\u0434\u0435\u0442, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0441\u043e\u0442\u044b\u0439 \u0438\u043c\u043f\u0443\u043b\u044c\u0441, \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u043d\u0430\u0441\u0447\u0438\u0442\u0430\u043b timer 4. \u0414\u0435\u043b\u0438\u043c \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 100 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/94e\/4e9\/816\/94e4e9816f5a593b4f1050335675338c.jpg\" width=\"2038\" height=\"1513\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/94e\/4e9\/816\/94e4e9816f5a593b4f1050335675338c.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/strong> \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0442\u0430\u0439\u043c\u0435\u0440\u0430 2, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u0421\u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u043e 100\u0433\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u0447\u0435\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 100 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b50\/0a2\/144\/b500a2144bee18c05b901224162e48ca.jpg\" width=\"749\" height=\"782\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b50\/0a2\/144\/b500a2144bee18c05b901224162e48ca.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 4 \u0434\u043b\u044f \u043e\u0442\u0441\u0447\u0435\u0442\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438:   <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/6b9\/ff1\/b60\/6b9ff1b604b57a8d9256c000dce863a7.jpg\" width=\"749\" height=\"766\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6b9\/ff1\/b60\/6b9ff1b604b57a8d9256c000dce863a7.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0423 \u043e\u0431\u043e\u0438\u0445 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435. <strong>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043a\u043e\u0434\u0443:<\/strong> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN PV *\/ volatile uint16_t num_per_tim = 0;    \/\/ \u043a\u043e\u043b-\u0432\u043e \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 volatile uint16_t time_tim = 0;       \/\/ \u0441\u044e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0441 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438-\u0448\u0435\u043b 10 \u0438\u043c\u043f\u0443\u043b\u044c\u0441 volatile uint16_t per_tim = 0;        \/\/ \u0441\u044e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 volatile uint8_t  flag_data = 0;      \/\/ \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0444\u043b\u0430\u0433\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0440\u0430 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c callback \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u0439\u043c\u0435\u0440 4 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041a\u043e\u043b-\u0432\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 4 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 num_per_tim, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 callback \u0442\u0430\u0439\u043c\u0435\u0440\u0430 4 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u0410 \u0432 callback \u0442\u0430\u0439\u043c\u0435\u0440\u0430 2 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u0438 \u0432\u0441\u0435 100 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 4. <\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN 4 *\/ \/*----------------------------------------------------------------------------*\/ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { \/\/ \u0435\u0441\u043b\u0438 \u0442\u0430\u0439\u043c\u0435\u0440 \u0434\u043e\u0441\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432\u0441\u0435 100 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434 Timer 2 ETR2, \u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b-\u0432\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 if (htim->Instance == TIM4) num_per_tim++; if (htim->Instance == TIM2) { time_tim = __HAL_TIM_GET_COUNTER(&amp;htim4); per_tim  = num_per_tim; num_per_tim = 0;                                   \/\/ \u0441\u0431\u0440\u043e\u0441 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 TIM4->CNT = 0;                                     \/\/ \u0441\u0431\u0440\u043e\u0441 \u0441\u0447\u0435\u0442\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 flag_data = 1; } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 flag_data \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443:<\/p>\n<pre><code class=\"cpp\">if (flag_data == 1) { float freq = 0; float period = time_tim + per_tim * 65536 + 1;             \/\/ \u043f\u0435\u0440\u0438\u043e\u0434 \u0432 \u0442\u0438\u043a\u0430\u0445 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 if (period != 0)                                           \/\/ \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u043b\u044c { period \/= 100;                                         \/\/ \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 freq = 72000000 \/ period; } else freq = 0; snprintf(buff, 80, \"Freq = %.3f\\r\\n\", freq); HAL_UART_Transmit_IT(&amp;huart1, buff, strlen(buff)); flag_data = 0; HAL_Delay(500); }<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0438\u043c \u0435\u0433\u043e \u043d\u0430 100 \u0438 \u0432\u0443\u0430\u043b\u044f, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0433\u043e\u0442\u043e\u0432\u043e. \u041f\u043e\u0434\u0430\u0434\u0438\u043c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 PA0 \u0441\u0438\u0433\u043d\u0430\u043b \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 10 \u043a\u0413\u0446:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/673\/d22\/497\/673d224977417ea2a813be4043c3c621.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/673\/d22\/497\/673d224977417ea2a813be4043c3c621.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441 \u0441\u0430\u043c\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c 100 \u043a\u0413\u0446: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/7bb\/d98\/5d7\/7bbd985d70c43762f7c1533b9fa794dd.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7bb\/d98\/5d7\/7bbd985d70c43762f7c1533b9fa794dd.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041d\u0443 \u0438 1 \u041c\u0413\u0446:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/8c5\/6a8\/c34\/8c56a8c34dab15574d99c54b664b8a22.jpg\" width=\"1920\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c5\/6a8\/c34\/8c56a8c34dab15574d99c54b664b8a22.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u0436\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. <\/p>\n<p><strong>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">+<\/p>\n<\/td>\n<td>\n<p align=\"center\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u043e\u043b\u044c\u0448\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433\u0438\u0445<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0443\u0436\u0435\u043d \u0446\u0435\u043b\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c ETR \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 \u0434\u043b\u044f \u0441\u0447\u0435\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f.\u00a0 \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0431\u044b\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u0435 \u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f. <\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0432\u044b\u0432\u043e\u0434\u0430\u043c\u0438 EXTI, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0437\u0430\u0445\u0432\u0430\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u043a\u043e\u0435 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435.<\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1x7JYhfKaMBydoTNVny3_L1OgFHKbVL78\/view?usp=sharing\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u044b<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/770478\/\"> https:\/\/habr.com\/ru\/articles\/770478\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 STM32. <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0436\u0435\u043b\u0435\u0437\u043e\u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0438\u0437\u043c\u0435\u0440\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430. \u041e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043d\u0435\u0433\u043e\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c \u043f\u044b\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0432\u043e\u0440\u043a\u0430\u0445 \u0434\u0438\u0441\u043a\u0430 D \u0438 \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043a\u043e\u043c\u0443-\u0442\u043e, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0441\u044f \u0432 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041d\u0430\u0448 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0441\u0442\u0435\u043d\u0434: \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b JDS6600 \u0438 BluePill<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043e\u0442 0 \u0434\u043e 10 \u043a\u0413\u0446. \u041c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 STM32F103C8T6, \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0430 bluepill. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 HAL. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u0432\u0443\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b <a href=\"https:\/\/supereyes.ru\/catalog\/waveform_generator\/generator_signalov_junce_jds6600_60m_2_kanala_kh_60_mgts\/\" rel=\"noopener noreferrer nofollow\">JDS6600<\/a>. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c CH340G (\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c USB &#8212; UART) \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (terminal v1.9b) \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438. \u0412 \u043d\u0435\u0433\u043e \u044f \u0431\u0443\u0434\u0443 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2013 <strong>\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430.<\/strong><\/p>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/strong> \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u0432\u044b\u0432\u043e\u0434\u0430\u043c \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 <strong>PA0<\/strong> \u0438 <strong>PA2<\/strong>. \u0412\u044b\u0432\u043e\u0434\u044b \u0437\u0435\u043c\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b.<\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/strong> \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 STM32IDE \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434 \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c UART \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 UART<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0430\u0441\u0442\u043e\u0442\u0443 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u043d\u0430 64 \u041c\u0413\u0446.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Timer 2. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0443\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043d\u0430\u043b 1 \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 (direct) \u043a\u0430\u043d\u0430\u043b, \u0430 \u043a\u0430\u043d\u0430\u043b 2 \u044d\u0442\u043e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 (indirect). \u041a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u0430 3 \u0438 4. \u0417\u0430\u0445\u0432\u0430\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u043e\u043d\u0442, \u0438 \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430. \u041f\u043e\u0441\u043b\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0434\u043d\u0438\u0439 \u0444\u0440\u043e\u043d\u0442, \u0438 \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \/ \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e. \u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0442\u0440\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u0441\u043a\u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 Timer 2: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0448\u0430\u0433, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u0433, \u0442\u0435\u043c \u0442\u043e\u0447\u043d\u0435\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u041f\u0440\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043c\u0435\u0440\u0430 64 \u041c\u0413\u0446 \u0438 \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435 = 64 (\u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 1 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043a\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0440\u0430\u0432\u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0435. \u041f\u0435\u0440\u0438\u043e\u0434 (Counter periode) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0434\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440 \u0434\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043b\u0443\u0447\u0448\u0435 \u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (Input Filter) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043c\u0435\u0445 \u0438 \u0448\u0443\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043c\u0435\u0445\u0438. \u0415\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d \u0438 \u043d\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d \u0441\u0438\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043c\u0435\u0445\u0430\u043c, \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0448\u0443\u043c\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430\u043c\u0438, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u042f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e Input Filter \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c. \u0412\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434:<\/strong> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">volatile uint16_t start1 = 0, end_imp1 = 0, end_per1 = 0, start2 = 0, end_imp2 = 0, end_per2 = 0;<\/code><\/pre>\n<p>\u0433\u0434\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 start \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430, end_imp \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430, end_ per \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430. 1 \u0438 2 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e CH1+CH2 \u0438 CH3+CH4.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f.<\/figcaption><\/div>\n<\/figure>\n<pre><code class=\"cpp\">volatile uint16_t period1 = 0, fill_factor1 = 0, long_imp1 = 0, period2 = 0, fill_factor2 = 0, long_imp2 = 0; volatile uint16_t freq1 = 0, freq2 = 0; volatile uint8_t flag_IC = 0; <\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u043b\u0430\u0433 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0441\u0438\u0433\u043d\u0430\u043b. \u0414\u0430\u043b\u0435\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u0435 \u043a\u0430\u043d\u0430\u043b\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e UART:<\/p>\n<pre><code class=\"cpp\">  \/* USER CODE BEGIN 2 *\/ HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_1); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_2); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_3); HAL_TIM_IC_Start_IT(&amp;htim2, TIM_CHANNEL_4);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 callback (\u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\/\u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f) \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN 4 *\/ \/*----------------------------------------------------------------------------*\/ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { if (htim->Instance == TIM2) { if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) { start1 = end_per1; end_per1 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_1); end_imp1 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_2); } if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) { start2 = end_per2; end_per2 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_3); end_imp2 = HAL_TIM_ReadCapturedValue(&amp;htim2, TIM_CHANNEL_4); } flag_IC = 1; } }<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u0439 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 \u00abflag_IC\u00bb, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u0445\u043e\u0434 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">\/*----------------------------------------------------------------------------*\/ void CALC_FREQ (void) { \/\/ \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u0445 (1 \u0438\u043c\u043f\u0443\u043b\u044c\u0441 = 1 \u043c\u043a\u0441) if (end_per1 > start1)  { period1 = end_per1 - start1; long_imp1 = end_imp1 - start1; if (period1 > 0) { freq1 = 1000000 \/ period1; fill_factor1 = (long_imp1 * 100) \/ period1; } } if (end_per2 > start2) { period2 = end_per2 - start2; long_imp2 = end_imp2 - start2; if (period2 > 0) { freq2 = 1000000 \/ period2; fill_factor2 = (long_imp2 * 100) \/ period2; } } }<\/code><\/pre>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u00abif (end_per1 > start1)\u00bb \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043e\u0431\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u0430 \u043a\u043e\u043d\u0435\u0446 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u043e \u043e\u0431\u0441\u0447\u0451\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0441\u0442\u0430\u043b \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e UART \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430:<\/p>\n<pre><code class=\"cpp\">if(flag_IC == 1) { CALC_FREQ(); snprintf(buff, 80, \"Freq 1 = %d fill_factor 1 = %d  Freq 2 = %d fill_factor 2 = %d\\r\\n\", freq1, fill_factor1, freq2, fill_factor2); HAL_UART_Transmit_IT(&amp;huart1, buff, strlen(buff)); HAL_Delay(500); flag_IC = 0; }<\/code><\/pre>\n<p>\u042f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0432\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 1\u043a\u0413\u0446 \u0438 850 \u0413\u0446. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 115200 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u043d\u043e \u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u043b. \u042f \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u043e\u0442 1 \u043a\u0413\u0446 \u0434\u043e 8 \u043a\u0413\u0446 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441 \u0448\u0430\u0433\u043e\u043c \u0432 1 \u043a\u0413\u0446 \u0438 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u044f \u043a\u0440\u0443\u0447\u0443 \u0440\u0443\u0447\u043a\u0443, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c. <\/p>\n<p><strong>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">+<\/p>\n<\/td>\n<td>\n<p align=\"center\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u0441\u043a\u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430.<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0442\u0430\u0439\u043c\u0435\u0440\u044b, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0442\u0430\u0439\u043c\u0435\u0440\u0443 \u043d\u0430 \u0434\u0432\u0430 \u0432\u0445\u043e\u0434\u0430. \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u043e\u0434 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u043e\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u0437\u0430 1 \u043f\u0435\u0440\u0438\u043e\u0434 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (\u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0435).<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u0430\u0439\u043c\u0435\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u043e 65 \u043c\u0441, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f,   \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 100 \u043c\u0441 (10 \u0413\u0446), \u0442\u043e \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445   \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u0439.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0415\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0440\u043e\u043f\u0430\u043b \u2013 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043d\u0435 \u043e\u0431\u043d\u0443\u043b\u0438\u0442\u0441\u044f \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b, \u0438 \u0435\u0441\u043b\u0438   \u043d\u0435\u0442, \u0442\u043e \u043e\u0431\u043d\u0443\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b, \u0438\u043b\u0438 \u0436\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u043b\u0430\u0433 \u043f\u0440\u0438   \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 callback.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b <strong>\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0430 EXTI<\/strong>.<\/p>\n<p>\u0412\u044b\u0432\u043e\u0434\u044b EXTI (External Interrupt) \u0443 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 STM32 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u043e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. EXTI \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u2013 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441, \u043c\u044b \u043f\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432, \u0430 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u043e. \u0422\u0430\u043a \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u0443.<\/p>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: <\/strong>\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u0432\u044b\u0432\u043e\u0434\u0430\u043c PA0 \u0438 PA1.<\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <\/strong>\u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b PA0 \u0438 PA1 \u043a\u0430\u043a \u0432\u044b\u0432\u043e\u0434\u044b EXTI. \u0422\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0443 \u043d\u0438\u0445. \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0444\u0440\u043e\u043d\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0432 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p><strong>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434:<\/strong>  <\/p>\n<pre><code class=\"cpp\">\/* USER CODE BEGIN PV *\/ volatile uint32_t num_imp1 = 0, num_imp2 = 0; uint32_t freq1 = 0, freq2 = 0; volatile uint8_t  flag_timer = 0; <\/code><\/pre>\n<p>\u0417\u0430\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441. \u041a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u043b\u0430\u0433, \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432. \u0412\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c callback \u043f\u043e EXTI \u0432\u044b\u0432\u043e\u0434\u0430\u043c:<\/p>\n<pre><code class=\"cpp\">void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {   if (GPIO_Pin == GPIO_PIN_0)   num_imp1++;   if (GPIO_Pin == GPIO_PIN_1)   num_imp2++; } <\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0443:<\/p>\n<pre><code class=\"cpp\">void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13); flag_timer = 1; freq1 = num_imp1; freq2 = num_imp2; num_imp1 = 0; num_imp2 = 0; }<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0437\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043f\u043e UART:<\/p>\n<pre><code class=\"cpp\">if (flag_timer == 1) { snprintf(buff, 80, \"Freq 1 = %d Freq 2 = %d\\r\\n\", freq1, freq2); HAL_UART_Transmit_IT(&amp;huart1, buff, strlen(buff)); flag_timer = 0; }<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0430\u0434\u0438\u043c 1 \u043a\u0413\u0446 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0438 5 \u043a\u0413\u0446 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 (\u043a\u0430\u043d\u0430\u043b ch2 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439):<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e <strong>\u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430\u0445 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445<\/strong>:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">+<\/p>\n<\/td>\n<td>\n<p align=\"center\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430\u043d\u043d\u044b<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-358726","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358726","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=358726"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358726\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}