{"id":208436,"date":"2014-01-08T13:47:03","date_gmt":"2014-01-08T09:47:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=208436"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=208436","title":{"rendered":"<span class=\"post_title\">\u0412\u044b\u0432\u043e\u0434 \u0437\u0432\u0443\u043a\u0430 \u043d\u0430 Arduino Due<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u043d\u0430 Arduino Due \u0431\u0435\u0437 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u043b\u0430\u0442\u0443 \u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0441\u043e \u0441\u043a\u0435\u0442\u0447\u0430\u043c\u0438, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 IDE \u0438 \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u041c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 Atmel Studio \u0432\u0435\u0440\u0441\u0438\u0438 6.0. \u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u0442\u0430 IDE, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Visual Studio 2010. \u041f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043e\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0412 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u043b\u0430\u0442\u0443 Arduino Due, \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0430-\u043b\u044f \u00abHello World\u00bb (\u043c\u0438\u0433\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c), \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0440\u0430\u0434\u043e\u0432\u0430\u043b\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043e\u0442 \u043c\u0435\u043d\u044f \u0441\u043b\u043e\u0435\u0432 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u041f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0430\u0441\u044c \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u044d\u0442\u043e \u043c\u0435\u043d\u044f \u0432 \u0438\u0442\u043e\u0433\u0435 \u0438 \u043f\u043e\u0434\u043a\u0443\u043f\u0438\u043b\u043e, \u0438 \u044f \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043d\u0430 Atmel Studio. \u0412 \u043d\u0435\u0435, \u043a\u0441\u0442\u0430\u0442\u0438, \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d Visual Assist, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u044b\u043c.<\/p>\n<p>  \u0418 \u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 DACC (Analog Converter Controller), \u043d\u043e \u0431\u0435\u0437 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 DACC \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u043f\u043e\u0440\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043e \u043d\u0435\u043c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043f\u043e\u0440\u0446\u0438\u044e.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c PDC (Peripheral DMA Controller) \u0438 TC (Timer Counter). \u0412 \u0438\u0442\u043e\u0433\u0435, \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u043e \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0443\u0447\u0438\u043b\u0441\u044f, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0432\u044b\u0432\u043e\u0434 \u0437\u0432\u0443\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 12-\u0442\u0438 \u0431\u0438\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b DACC, \u0434\u0435\u043b\u0430\u044f \u043f\u0430\u0443\u0437\u044b \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e \u0432\u044b\u0432\u043e\u0434\u0443 \u0437\u0432\u0443\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 Atmel Studio (DAC Sinewave Example). \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 (System Timer), \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0432 \u043a\u0430\u043d\u0430\u043b DACC. \u0422\u043e\u0436\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u043d\u043e \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b 32 \u043a\u0413\u0446 \u043d\u0430\u043c \u0443\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f 32000 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0442.\u043a. \u0435\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 DACC \u043f\u043e\u0440\u0446\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PDC, \u043d\u043e \u043e\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u043f\u0430\u0443\u0437\u044b, \u0442.\u0435. \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043a\u043e\u0433\u0434\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0441\u043b\u043e\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0436\u0435\u043b\u0435\u0437\u043e\u043c \u0438 \u0442\u0443\u0442 \u0436\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u043d\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0442.\u043a. \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b DACC, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0443\u043c\u0435\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TC \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 TC \u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c DACC, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 TC.<\/p>\n<p>  TC \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0435\u0436\u0438\u043c \u201cwaveform\u201d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 Ra \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0443\u043d\u0442\u0435\u0440\u0430, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u043b, \u0430 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 Rc \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 Ra + 1), \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u043b \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 DACC.<\/p>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 PDC \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 ROM, \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 RAM.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u043e\u0434\u0443\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0437\u0432\u0443\u043a\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 sound.c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>\/\/ \u041a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 static uint16_t g_buffer[4096]; \/\/ \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u0443, \u0445\u0432\u043e\u0441\u0442 \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 static volatile uint16_t g_buffer_head, g_buffer_tail, g_buffer_size;  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 static inline uint16_t get_continuous_data_size_irq(void) {     return g_buffer_head &lt;= g_buffer_tail ? g_buffer_tail - g_buffer_head : ARRAYSIZE(g_buffer) - g_buffer_head; }  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 static inline uint16_t get_buffer_capacity(void) {     return g_buffer_size; }  \/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 static uint16_t copy_in_buffer(const uint16_t * data, uint16_t size) {     uint16_t tail = g_buffer_tail;          \/\/ \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a     uint32_t to_copy = min(size, ARRAYSIZE(g_buffer) - tail);     memcpy((void *)(g_buffer + tail), (void *)data, (size_t)(to_copy &lt;&lt; 1));          if (to_copy &lt; size)     {         \/\/ \u0427\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0431\u0443\u0444\u0435\u0440\u0430         memcpy(g_buffer, data + to_copy, (size - to_copy) &lt;&lt; 1);         tail = size - to_copy;     }            else     {         \/\/ \u0412\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0444\u0435\u0440\u0430         tail += size;     }          return tail; }  \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0435\u043c\u043a\u043e\u0441\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u0430 static inline void move_head_irq(uint16_t size) {     g_buffer_head += size;     g_buffer_size += size;     if (g_buffer_head &gt;= ARRAYSIZE(g_buffer) && g_buffer_head &gt; g_buffer_tail)         g_buffer_head -= ARRAYSIZE(g_buffer); }  \/\/ \u0414\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PDC  \/\/ \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 static pdc_packet_t g_pdc_packet; \/\/ \u0420\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 PDC static volatile uint32_t g_pdc_packet_size; \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435 0, \u0442\u043e PDC \u0432\u0441\u0435 \u0435\u0449\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d static volatile uint8_t g_pdc_active;  \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 DACC static inline void disable_irq(void) {     dacc_disable_interrupt(DACC, DACC_IER_ENDTX); }  \/\/ \u0415\u0441\u043b\u0438 PDC \u0430\u043a\u0442\u0438\u0432\u0435\u043d, \u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 DACC static inline void restore_irq(void) {     if (g_pdc_active)         dacc_enable_interrupt(DACC, DACC_IER_ENDTX); }  #define DACC_PDC_PACKET_MAX_SIZE 512  \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 DACC \/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u0431\u044b\u043b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d PDC void DACC_Handler(void) {     \/\/ \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f     uint32_t status = dacc_get_interrupt_status(DACC);      if (status & DACC_IER_ENDTX)     {         \/\/ \u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440         move_head_irq(g_pdc_packet_size);         uint16_t data_size = get_continuous_data_size_irq();          if (data_size == 0)         {             \/\/ \u041a\u043e\u043d\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435             g_pdc_packet_size = 0;             g_pdc_active = 0;             \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 DACC             dacc_disable_interrupt(DACC, DACC_IDR_ENDTX);         }         else         {             \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c PDC \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430             g_pdc_packet.ul_addr = (uint32_t)(g_buffer + g_buffer_head);             g_pdc_packet_size = min(DACC_PDC_PACKET_MAX_SIZE, data_size);             g_pdc_packet.ul_size = g_pdc_packet_size;                          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c             pdc_tx_init(PDC_DACC, &g_pdc_packet, NULL);         }     } }  \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043d\u0430\u043b 0 TC \u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 static void tc_adjust_frequency(uint16_t frequency) {     uint32_t divider = sysclk_get_cpu_hz() \/ frequency;     divider &gt;&gt;= 1;      tc_write_ra(TC0, 0, divider);     tc_write_rc(TC0, 0, divider + 1); }  \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0436\u0435\u043b\u0435\u0437\u043e void sound_init_hardware(void) {     \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c TC     sysclk_enable_peripheral_clock(ID_TC0);      \/\/ \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c TC0 \u0432 \u0440\u0435\u0436\u0438\u043c waveform     tc_init(TC0, 0,             TC_CMR_TCCLKS_TIMER_CLOCK1             | TC_CMR_WAVE \/* Waveform mode is enabled *\/             | TC_CMR_ACPA_SET \/* RA Compare Effect: set *\/             | TC_CMR_ACPC_CLEAR \/* RC Compare Effect: clear *\/             | TC_CMR_CPCTRG \/* UP mode with automatic trigger on RC Compare *\/     );      \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0434\u043b\u044f TC, \u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u0443\u044e     tc_adjust_frequency(8000);      \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440     tc_start(TC0, 0);      \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c DACC     sysclk_enable_peripheral_clock(ID_DACC);      \/\/ \u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b DACC     dacc_reset(DACC);      \/\/ \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c DACC \u0432 \u0440\u0435\u0436\u0438\u043c &quot;half word&quot;     dacc_set_transfer_mode(DACC, 0);      \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u044e \u044d\u043d\u0435\u0440\u0433\u0438\u0438     dacc_set_power_save(DACC, 0, 0);      \/\/ \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u0430\u043d\u0430\u043b TC0 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430     dacc_set_trigger(DACC, 1);      \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c TAG \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b DACC     dacc_set_channel_selection(DACC, 1);      \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u043d\u0430\u043b DACC     dacc_enable_channel(DACC, 1);      \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u0430\u043d\u0430\u043b\u0430     dacc_set_analog_control(DACC, DACC_ACR_IBCTLCH0(0x02) | DACC_ACR_IBCTLCH1(0x02) | DACC_ACR_IBCTLDACCORE(0x01));          \/\/ \u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f DACC \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438     NVIC_DisableIRQ(DACC_IRQn);     NVIC_ClearPendingIRQ(DACC_IRQn);     NVIC_EnableIRQ(DACC_IRQn);      \/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 PDC \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 DACC     pdc_enable_transfer(PDC_DACC, PERIPH_PTCR_TXTEN);          \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     g_pdc_packet_size = 0;     g_pdc_active = 0; }  \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b void sound_start(uint16_t frequency) {     \/\/ \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0441\u0442\u043e\u043f     sound_stop();     \/\/ \u041f\u0435\u0440\u0435\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0442\u0430\u0439\u043c\u0435\u0440     tc_adjust_frequency(frequency); }     \/\/ \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u0437\u0432\u0443\u043a\u0430 void sound_stop(void) {     \/\/ \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 DACC \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u044b     dacc_disable_interrupt(DACC, DACC_IER_ENDTX);      g_pdc_packet_size = 0;     g_buffer_head = g_buffer_tail = 0;     g_buffer_size = ARRAYSIZE(g_buffer);     g_pdc_active = 0; }  \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u043f\u043e\u0440\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0437\u0432\u0443\u043a\u0430 uint8_t sound_data(const uint16_t * data, uint16_t size) {     \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u043c\u043a\u043e\u0441\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u0430     uint16_t capacity = get_buffer_capacity();     if (capacity &lt; size)         return 0;              \/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440     uint16_t tail = copy_in_buffer(data, size);     \/\/ \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0444\u0435\u0440\u0430     disable_irq();     g_buffer_tail = tail;     g_buffer_size -= size;     if (g_buffer_head &gt;= ARRAYSIZE(g_buffer))         g_buffer_head -= ARRAYSIZE(g_buffer);     g_pdc_active = 1;     restore_irq();          \/\/ \u0412\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e     return 1; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#include &lt;asf.h&gt;  #include &quot;sound.h&quot;  #define STRING_HEADER &quot;-- Sound firmware --\\r\\n&quot; \\ &quot;-- &quot;BOARD_NAME&quot; --\\r\\n&quot; \\ &quot;-- Compiled: &quot;__DATE__&quot; &quot;__TIME__&quot; --\\r&quot;  static void configure_console(void) {     const usart_serial_options_t uart_serial_options = {         .baudrate = 115200,         .paritytype = UART_MR_PAR_NO     };      sysclk_enable_peripheral_clock(ID_UART);     stdio_serial_init(UART, &uart_serial_options); }   #include &quot;sound_data.c&quot; static uint32_t g_sound_pos = 0;  int main (void) {     sysclk_init();     board_init();     configure_console();      puts(STRING_HEADER);     printf(&quot;CPU Frequency %li MHz\\r\\n&quot;, sysclk_get_cpu_hz() \/ 1000000);          sound_init_hardware();     sound_start(16000);      puts(&quot;Work...\\r&quot;);          while (1)     {         \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u043e 512 \u0441\u043b\u043e\u0432 \u0438\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c         uint32_t size = min(512, ARRAYSIZE(g_sound_data) - g_sound_pos);         if (sound_data(g_sound_data + g_sound_pos, size))         {             \/\/ \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0431\u0443\u0444\u0435\u0440             g_sound_pos += size;             if (g_sound_pos &gt;= ARRAYSIZE(g_sound_data))                 g_sound_pos = 0;         }         else         {             \/\/ \u041d\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435, \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437           }                } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0432\u043e\u0434\u0430, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0434\u0430\u0447\u0438 \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043a \u043a\u043e\u043d\u0446\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0432 \u043a\u043e\u043d\u0446\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0442\u0430\u043c \u0437\u0432\u0443\u043a \u044f \u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 USB, \u0442\u0430\u043a \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u0443\u0437\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 512 \u043f\u043e\u043b\u0443\u0441\u043b\u043e\u0432, \u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0437\u0432\u0443\u043a\u0430 8 \u043a\u0413\u0446, \u0442\u043e \u043f\u0430\u0443\u0437\u0430 \u043c\u0435\u0436\u0434\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 512 \/ 8000 = 64 \u043c\u0441.<\/p>\n<p>  \u0411\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u043d\u0435 \u0438\u0437 ROM. \u0410 \u0435\u0449\u0435 PDC \u0443\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u043f\u0430\u043a\u0435\u0442\u0430, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0437\u0432\u0443\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0432 \u0435\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u043d\u0430 2\/3 \u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043c\u0430 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0430\u043b\u0441\u044f.<\/p>\n<p>  \u041f\u0440\u043e\u0448\u0438\u0432\u0430\u043b \u043f\u043b\u0430\u0442\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438\u0437 IDE Arduino, \u0431\u044b\u043b\u043e \u043b\u0435\u043d\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b, \u0438 \u044d\u0442\u043e\u0442 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<br \/>  <code>bossac.exe --port=COM4 -U false -e -w -v -b sound.bin \u2013R<\/code><\/p>\n<p>  bossac.exe \u2013 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0438\u0437 Arduino IDE<br \/>  \u0418\u043c\u044f COM-\u043f\u043e\u0440\u0442\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0435.<br \/>  \u0424\u0430\u0439\u043b \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 Debug \u0438\u043b\u0438 Release \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u041f\u0440\u043e\u0435\u043a\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/github.com\/artalex\/arduino_due_sound\">github.com\/artalex\/arduino_due_sound<\/a><\/p>\n<p>  \u0412 Atmel Studio \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0434\u043b\u044f Arduino Due, \u043e\u0447\u0435\u043d\u044c \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0445 \u0438\u0437\u0443\u0447\u0438\u0442\u044c.<\/p>\n<p>  \u0420\u0430\u0441\u043f\u0438\u043d\u043e\u0432\u043a\u0430 \u043f\u043b\u0430\u0442\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0437\u0434\u0435\u0441\u044c <a href=\"http:\/\/arduino.cc\/en\/Hacking\/PinMappingSAM3X\">arduino.cc\/en\/Hacking\/PinMappingSAM3X<\/a>.<br \/>  \u0412\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 SAM3X: <a href=\"http:\/\/www.atmel.com\/Images\/doc11057.pdf\">www.atmel.com\/Images\/doc11057.pdf<\/a>.<\/p>\n<p>  \u041c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c wave2hex.py. \u041e\u043d \u043b\u0435\u0436\u0438\u0442 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 scripts \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a: <code>wave2hex.py \u2013I some.wav<\/code>, \u0433\u0434\u0435 some.wav \u2013 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \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\/208436\/\"> http:\/\/habrahabr.ru\/post\/208436\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u043d\u0430 Arduino Due \u0431\u0435\u0437 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u043b\u0430\u0442\u0443 \u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0441\u043e \u0441\u043a\u0435\u0442\u0447\u0430\u043c\u0438, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 IDE \u0438 \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u041c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 Atmel Studio \u0432\u0435\u0440\u0441\u0438\u0438 6.0. \u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u0442\u0430 IDE, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Visual Studio 2010. \u041f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043e\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0412 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u043b\u0430\u0442\u0443 Arduino Due, \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0430-\u043b\u044f \u00abHello World\u00bb (\u043c\u0438\u0433\u0430\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c), \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0440\u0430\u0434\u043e\u0432\u0430\u043b\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043e\u0442 \u043c\u0435\u043d\u044f \u0441\u043b\u043e\u0435\u0432 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u041f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0430\u0441\u044c \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u044d\u0442\u043e \u043c\u0435\u043d\u044f \u0432 \u0438\u0442\u043e\u0433\u0435 \u0438 \u043f\u043e\u0434\u043a\u0443\u043f\u0438\u043b\u043e, \u0438 \u044f \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043d\u0430 Atmel Studio. \u0412 \u043d\u0435\u0435, \u043a\u0441\u0442\u0430\u0442\u0438, \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d Visual Assist, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u044b\u043c.<\/p>\n<p>  \u0418 \u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0432\u0443\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 DACC (Analog Converter Controller), \u043d\u043e \u0431\u0435\u0437 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 DACC \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u043f\u043e\u0440\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043e \u043d\u0435\u043c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043f\u043e\u0440\u0446\u0438\u044e.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c PDC (Peripheral DMA Controller) \u0438 TC (Timer Counter). \u0412 \u0438\u0442\u043e\u0433\u0435, \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u043e \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0443\u0447\u0438\u043b\u0441\u044f, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/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-208436","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/208436","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=208436"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/208436\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}