{"id":167319,"date":"2013-01-28T12:08:02","date_gmt":"2013-01-28T08:08:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=167319"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=167319","title":{"rendered":"<span class=\"post_title\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 AVR assembler \u0431\u0435\u0437 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h5><b>\u0410 \u0437\u0430\u0447\u0435\u043c?<\/b><\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0441 \u0421\u0438 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 (\u043d\u0443\u0436\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c) \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u043b\u043e\u0445\u0443\u044e \u0432\u0435\u0449\u044c, \u043d\u0430 \u043d\u0435\u043c \u043d\u0435\u0442 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 _delay_ms(long millisecond) (\u043f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u043b, \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043a\u0430\u043b \u043f\u043b\u043e\u0445\u043e), \u043f\u0438\u0441\u0430\u0442\u044c 8000 \u043f\u0443\u0441\u0442\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0434\u043b\u044f 8 \u041c\u0433\u0446 \u0447\u0442\u043e\u0431\u044b 1 \u043c\u0441 \u0443\u0434\u0435\u0440\u0436\u0430\u0442\u044c) \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0431\u0440\u0435\u0434, \u043e\u0442\u0441\u044e\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Delay.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5><b>\u0428\u0430\u0433 \u0417\u0430 \u0428\u0430\u0433\u043e\u043c<\/b><\/h5>\n<p>  \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0432\u043e\u0435\u0439 \u0438\u0434\u0435\u0435\u0439, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043a\u0438\u043d\u0443\u043b\u0441\u044f \u0432 \u0431\u043e\u0439, \u043e\u0441\u043e\u0431\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u044f, \u0440\u0435\u0448\u0438\u043b \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0440\u044f\u0442\u044c \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u041a\u043e\u0434 \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d, <\/p>\n<pre><code>.macro DELAY_MS \tpush R16\t\t\t\t \tpush R17 \tpush R24 \tpush R28  \tldi R28, LOW(@0) \tldi R24, HIGH(@0) \trjmp cycMKS\t  cycSEK: \t\t\t\t \tsubi R24,1 \tldi R28, 255 cycMKS:\t\t\t\t\t  \tcpi R28, 1\t\t \tbrlo decMKS\t\t\t\t \tsubi R28,1\t\t\t\t \t ldi R16, LOW(@1\/1000)\t \tldi R17, HIGH(@1\/1000) \trjmp _delay_c  new_cycle:  \tsubi R17, 1 \tldi R16, 255 _delay_c:\t\t\t\t\t \tsubi R16, 4\t\t\t\t \tcpi R16, 4\t\t\t\t \tbrsh _delay_c\t\t\t \tNOP\t\t\t \tNOP \tcpi R17, 0\t\t\t \tbrne new_cycle\t\t\t \trjmp cycMKS\t\t\t  decMKS:\t\t\t\t\t\t  \tcpi R24,0\t\t\t\t \tbrne cycSEK\t\t\t\t   \tpop R28\t\t\t\t\t \tpop R24\t\t\t\t\t \tpop R17\t\t\t\t\t \tpop R16\t\t\t\t\t .endm  <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e AVR Studio 4 + gcc, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043e\u0434 \u0442\u043e\u0436\u0435 \u0442\u0430\u043c. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d46\/396\/150\/d46396150ec0ab5a45b519881acecaed.jpg\"\/><\/p>\n<p>  \u2026<br \/>  .equ F_CPU = 8000000; \u0427\u0430\u0441\u0442\u043e\u0442\u0430 \u0432 \u0413\u0446<br \/>  \u2026<br \/>  DELAY_MS 4, F_CPU; \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0434\u043b\u044f 4 \u043c\u0441<br \/>  \u2026<\/p>\n<p>  \u0421\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c, \u0440\u0430\u0441\u0442\u0443\u0449\u0430\u044f \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438, \u043f\u0440\u044f\u043c\u043e \u0443\u0434\u0430\u0440\u0438\u043b\u0430 \u043f\u043e \u0433\u043b\u0430\u0437\u0443, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0441\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0420\u0435\u0448\u0438\u043b \u043f\u043e\u0439\u0442\u0438 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443, \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0426\u0438\u043a\u043b\u043e\u0432 \u0434\u043b\u044f 1 \u0431\u0430\u0439\u0442\u0430, 2 \u0431\u0430\u0439\u0442\u043e\u0432, \u0438 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435, \u0441\u043a\u043b\u0435\u0438\u0432 \u0432\u0441\u0435 \u044d\u0442\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445.<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u0438\u043b\u043e\u0441\u044c 3 \u043c\u0430\u043a\u0440\u043e\u0441\u0430:<\/p>\n<pre><code>; \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 \u0446\u0438\u043a\u043b\u0430\u0445 ; @0 \u2013 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 9-255 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u043a\u043b\u043e\u0432) .macro DELAY_CL \t;push R16 \t \tldi R16, LOW(@0)-5 _delay_cl: \tsubi R16, 4 \tcpi R16, 4 \tbrsh _delay_cl \t \tcpi R16, 1 \tbreq end_cl_1\t \tcpi R16, 0 \tbreq end_cl \tcpi R16, 2 \tbreq end_cl \trjmp end_cl \t\t\t end_cl_1: \tNOP \tNOP \tNOP end_cl: .endm\t  <\/code><\/pre>\n<pre><code>; \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 \u0446\u0438\u043a\u043b\u0430\u0445 ; @0 \u2013 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 9-255 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u043a\u043b\u043e\u0432) .macro DELAY_CL \t;push R16 \t \tldi R16, LOW(@0)-5 _delay_cl: \tsubi R16, 4 \tcpi R16, 4 \tbrsh _delay_cl \t \tcpi R16, 1 \tbreq end_cl_1\t \tcpi R16, 0 \tbreq end_cl \tcpi R16, 2 \tbreq end_cl \trjmp end_cl \t\t\t end_cl_1: \tNOP \tNOP \tNOP end_cl: .endm\t  <\/code><\/pre>\n<p>  \u0426\u0438\u043a\u043b\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u0445 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e.<\/p>\n<pre><code>; \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 \u043c\u0438\u043b\u0435\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 ;  @0 \u2013 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 1 \u2013 65535 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434) ; @1 \u2013 \u0427\u0430\u0441\u0442\u043e\u0442\u0430 \u0432 \u0413\u0435\u0440\u0446\u0430\u0445 ( &gt;= 1,3 MHz) .macro DELAY_MS \tpush R19\t\t\t\t \tpush R18\t\t\t\t \tpush R17\t\t\t\t \tpush R16\t\t\t\t  \tldi R18, LOW(@0)\t\t \tldi R19, HIGH(@0)\t\t  \tcpi R18, 0\t\t\t\t \tbreq re_init \t\t\t _cicl_msl: \tDELAY_C @1\/1000\t\t\t \tsubi R18, 1\t\t\t\t \tcpi R18, 0\t\t\t\t \tbreq re_init \t\t\t \trjmp _cicl_msl\t\t\t re_init: \tcpi R19, 0\t\t\t \tbreq _end_c\t\t\t\t \tsubi R19, 1\t\t\t\t \tldi R18, 255\t\t\t \tDELAY_C (@1\/1000)-255*5\t \trjmp _cicl_msl  _end_c:  \tpop R16 \tpop R17 \tpop R18 \tpop R19 .endm  <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b:<\/p>\n<p>  \u0414\u043b\u044f 1 \u043c\u0441 (Atmega8535, F_CPU = 8001000 Hz)<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f0a\/02a\/b85\/f0a02ab85f86ad4d14f2c7fd69560a5e.jpg\"\/><br \/>  \u0414\u043b\u044f 300\u043c\u0441 (Atmega8535, F_CPU = 8001000 Hz)<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/570\/09b\/813\/57009b8133480c54b5dd87ba469671cc.jpg\"\/><br \/>  \u0414\u043b\u044f 32\u0441 (Atmega8535, F_CPU = 8001000 Hz)<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/0a7\/fe8\/c19\/0a7fe8c19c8ba6a84bfb714b4a62b646.jpg\"\/><br \/>  \u0414\u043b\u044f 300\u043c\u0441 (Atmega6490, F_CPU = 4000000 Hz)<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/e04\/3d3\/1ac\/e043d31ac1a75080aa65cfed4e0141ce.jpg\"\/><br \/>  \u0414\u043b\u044f 300\u043c\u0441 (ATtiny43U, F_CPU = 2000000 Hz)<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/7e6\/67e\/1a0\/7e667e1a027351ecd5d3adca3606ec21.jpg\"\/><\/p>\n<p>  \u041f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0436\u0438\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 ~4-150 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434. \u042d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. <br \/>  \u0425\u043e\u0442\u0435\u043b \u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 DELAY_MS \u043d\u0430 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 (\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u043e), \u043d\u043e \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043e\u043c \u043a\u043e\u0432\u044b\u0440\u044f\u044e\u0441\u044c \u043d\u0435\u0434\u0435\u043b\u0438 2, \u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u043a\u0430\u043a \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043d\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/167319\/\"> http:\/\/habrahabr.ru\/post\/167319\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h5><b>\u0410 \u0437\u0430\u0447\u0435\u043c?<\/b><\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0441 \u0421\u0438 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 (\u043d\u0443\u0436\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c) \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u043b\u043e\u0445\u0443\u044e \u0432\u0435\u0449\u044c, \u043d\u0430 \u043d\u0435\u043c \u043d\u0435\u0442 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 _delay_ms(long millisecond) (\u043f\u043e\u0438\u0441\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u043b, \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043a\u0430\u043b \u043f\u043b\u043e\u0445\u043e), \u043f\u0438\u0441\u0430\u0442\u044c 8000 \u043f\u0443\u0441\u0442\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0434\u043b\u044f 8 \u041c\u0433\u0446 \u0447\u0442\u043e\u0431\u044b 1 \u043c\u0441 \u0443\u0434\u0435\u0440\u0436\u0430\u0442\u044c) \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0431\u0440\u0435\u0434, \u043e\u0442\u0441\u044e\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0434\u0435\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 Delay.  <\/p>\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-167319","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167319","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=167319"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167319\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}