{"id":2823,"date":"2014-09-17T23:48:06","date_gmt":"2014-09-17T19:48:06","guid":{"rendered":"http:\/\/avr-start.ru\/?p=2823"},"modified":"2018-12-13T23:22:21","modified_gmt":"2018-12-13T19:22:21","slug":"2823","status":"publish","type":"post","link":"https:\/\/avr-start.ru\/?p=2823","title":{"rendered":"\u041f\u041b\u0418\u0421. SPI"},"content":{"rendered":"<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0431\u0430\u0439\u0442\u0430 \u043f\u043e UART, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u043d\u0430 \u041f\u041a. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u043a \u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u0438\u0442\u044c AVR \u0438 \u041f\u041b\u0418\u0421.<br \/>\n<!--more--><\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0443\u043b\u044f. \u0412 ASCII \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0x30, \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435 0b 0011 0000. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 spi \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u0430\u0439\u0442 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0435\u0434\u043e\u043c\u043e\u0433\u043e &#8212; \u043f\u0440\u0438\u0436\u0430\u0442\u044c \u043d\u043e\u0436\u043a\u0443 SS \u043a \u0437\u0435\u043c\u043b\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b. \u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0441 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f 8 \u0431\u0438\u0442. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0442\u043e\u043f \u0431\u0438\u0442\u043e\u0432, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0442\u0430\u0440\u0442 \u0431\u0438\u0442\u043e\u0432. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0431\u0438\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u043e \u043f\u043e \u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430, \u043b\u0438\u0431\u043e \u043f\u043e \u043d\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0432\u0430\u0436\u043d\u043e \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u043d\u0438\u044f SCLK, \u043b\u0438\u0431\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043d\u043e\u043b\u044c, \u043b\u0438\u0431\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0430. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f 4 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b SPI. \u0420\u0435\u0436\u0438\u043c 0, \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 SCLK \u043b\u043e\u0433 0. \u0411\u0438\u0442\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode0_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode0_1.png\" alt=\"mode0_1\" width=\"425\" height=\"160\" class=\"aligncenter size-full wp-image-2834\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode0_1.png 425w, https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode0_1-300x112.png 300w\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" \/><\/a><\/p>\n<p>\u0420\u0435\u0436\u0438\u043c 1. \u041a\u043e\u0433\u0434\u0430 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0441\u0438\u0433\u043d\u0430\u043b \u043d\u0430 \u043d\u043e\u0433\u0435 SCLK \u0440\u0430\u0432\u0435\u043d \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u0443\u043b\u044e. \u0418 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode1_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode1_1.png\" alt=\"mode1_1\" width=\"397\" height=\"160\" class=\"aligncenter size-full wp-image-2835\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode1_1.png 397w, https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode1_1-300x120.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/a><\/p>\n<p>\u0420\u0435\u0436\u0438\u043c 2. \u041a\u043e\u0433\u0434\u0430 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0441\u0438\u0433\u043d\u0430\u043b \u043d\u0430 \u043d\u043e\u0433\u0435 SCLK \u0440\u0430\u0432\u0435\u043d \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435. \u0418 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode2_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode2_1.png\" alt=\"mode2_1\" width=\"400\" height=\"154\" class=\"aligncenter size-full wp-image-2836\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode2_1.png 400w, https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode2_1-300x115.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u0420\u0435\u0436\u0438\u043c 3. \u041a\u043e\u0433\u0434\u0430 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0441\u0438\u0433\u043d\u0430\u043b \u043d\u0430 \u043d\u043e\u0433\u0435 SCLK \u0440\u0430\u0432\u0435\u043d \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u0443\u043b\u044e. \u0418 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443.<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode3_1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode3_1.png\" alt=\"mode3_1\" width=\"416\" height=\"158\" class=\"aligncenter size-full wp-image-2837\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode3_1.png 416w, https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/mode3_1-300x113.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/a><\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u0436\u0435\u043d \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432 MSB \u0438\u043b\u0438 LSB, \u0442.\u0435. \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c 0011 0000 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u043b\u0435\u0432\u043e, \u043b\u0438\u0431\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430 \u043f\u0440\u0430\u0432\u043e.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0435\u0441\u0442\u044c \u0412 CAVR<br \/>\n<a href=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/cavr_spi.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/cavr_spi.png\" alt=\"cavr_spi\" width=\"478\" height=\"472\" class=\"aligncenter size-full wp-image-2841\" srcset=\"https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/cavr_spi.png 478w, https:\/\/avr-start.ru\/wp-content\/uploads\/2014\/09\/cavr_spi-300x296.png 300w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><\/a><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0442\u044c. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0440\u043e\u043b\u0438 &#171;\u0433\u043e\u0441\u043f\u043e\u0434\u0438\u043d\u0430&#187; AVR \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c PD0 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043b\u044c, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c PD1 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430. <\/p>\n<pre lang=\"c\">\r\n#include <mega8.h>\r\n#include <spi.h>\r\n\r\nvoid main(void)\r\n{\r\n\/\/ Function: Bit7=In Bit6=In Bit5=Out Bit4=In Bit3=Out Bit2=Out Bit1=In Bit0=In \r\nDDRB=(0<<DDB7) | (0<<DDB6) | (1<<DDB5) | (0<<DDB4) | (1<<DDB3) | (1<<DDB2) | (0<<DDB1) | (0<<DDB0);\r\n\/\/ State: Bit7=T Bit6=T Bit5=0 Bit4=T Bit3=0 Bit2=0 Bit1=T Bit0=T \r\nPORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);\r\n\r\n\/\/ Port D initialization\r\n\/\/ Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In \r\nDDRD=(0<<DDD7) | (0<<DDD6) | (0<<DDD5) | (0<<DDD4) | (0<<DDD3) | (0<<DDD2) | (0<<DDD1) | (0<<DDD0);\r\n\/\/ State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=P Bit0=P \r\nPORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (1<<PORTD1) | (1<<PORTD0);\r\n\r\n\/\/ SPI initialization\r\n\/\/ SPI Type: Master\r\n\/\/ SPI Clock Rate: 2000,000 kHz\r\n\/\/ SPI Clock Phase: Cycle Start\r\n\/\/ SPI Clock Polarity: Low\r\n\/\/ SPI Data Order: MSB First\r\nSPCR=(0<<SPIE) | (1<<SPE) | (0<<DORD) | (1<<MSTR) | (0<<CPOL) | (0<<CPHA) | (0<<SPR1) | (0<<SPR0);\r\nSPSR=(0<<SPI2X);\r\n\r\nwhile (1)\r\n      {\r\n        if(PIND.0==0)\r\n        {\r\n            spi('0');\r\n        }\r\n        if(PIND.1==0)\r\n        {            \r\n            spi('1');\r\n        }\r\n      }\r\n}\r\n<\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \"\u0440\u0430\u0431\u0430\" \u0431\u0443\u0434\u0435\u0442 \u043f\u043b\u0438\u0441\u0438\u043d\u0430<\/p>\n<pre lang=\"c\">\r\nmodule test_spi(clk,Mosi,ss,led);\r\ninput clk; \/\/\u0441\u044e\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u043b\u044f\u0442 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0435 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b\r\ninput ss; \/\/\u0432\u044b\u0431\u043e\u0440 \u0447\u0438\u043f\u0430\r\ninput Mosi; \/\/\u043d\u043e\u0436\u043a\u0430 \u043f\u0440\u0438\u0435\u043c\u0430\r\noutput reg led = 0; \/\/\u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0438\u043a\r\nreg [7:0]data = 0; \r\nreg [3:0]nBit = 0;\r\nreg [8:0]clock = 0;\r\n \r\nalways @ (posedge clk) \/\/\u043f\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0443 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432\r\nbegin\r\n\tif(ss==0) \/\/\u0435\u0441\u043b\u0438 \u0447\u0438\u043f \u0441\u0435\u043b\u0435\u043a\u0442 \u0440\u0430\u0432\u0435\u043d \u043b\u043e\u0433 \u043d\u0443\u043b\u044e\r\n\tbegin\r\n\t\tif(nBit != 8)begin\r\n\t\t\tdata[7:0] <= {data[6:0],Mosi}; \/\/\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0431\u0438\u0442 \u0438 \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435\r\n\t\t\tnBit <= nBit + 1; \/\/\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u0438\u0442\r\n\t\tend\r\n\r\n\t\tif(nBit == 8)begin \/\/\u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442 \u043f\u0440\u0438\u0448\u0435\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043c\u043e\u0442\u0440\u0438\u043c\r\n\t\t\tif(data == 8'b00110000)begin led = 1'b1; end \/\/\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u0435\u043b '0' \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\r\n\t\t\tif(data == 8'b00110001)begin led = 1'b0; end \/\/\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u043b\u0430 '1' \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\r\n\t\t\tnBit <= 0;\r\n\t\tend\r\n\tend\r\nend\r\n\r\nendmodule\r\n<\/pre>\n<p>\u041e\u0441\u043e\u0431\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430<\/p>\n<pre lang=\"c\">data[7:0] <= {data[6:0],Mosi};\r\n<\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0434\u044b\u043c\u0438\u043b\u0441\u044f \u043c\u043e\u0437\u0433, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0432\u043a\u0443\u0440\u0438\u043b. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0430 \u043c\u0430\u043d\u0435\u0440 \u0421\u0438, \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<pre lang=\"c\">char data[3] = {1, 2, 3};<\/pre>\n<p> \u0442.\u0435. 3 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u0438 3 \u0447\u0438\u0441\u043b\u0430<br \/>\n\u0417\u0434\u0435\u0441\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0435\u0441\u043b\u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre lang=\"c\">data[7:0] <= {data[6],data[5],data[4],data[3],data[2],data[1],data[0],Mosi};\r\n<\/pre>\n<p>\u0442.\u0435. \u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c data[7:1] \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f data[6:0], \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e data[0] \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Mosi, \u0442.\u0435. \u0442\u043e \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043d\u043e\u0436\u043a\u0435. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0441\u0434\u0432\u0438\u0433 \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u041f\u041b\u0418\u0421\u0438\u043d\u044b, \u0430 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u0442\u043e, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 SPI \u043d\u0430 2\u041c\u0413\u0446, \u0442.\u0435. \u0431\u0430\u0439\u0442 \u0443\u0439\u0434\u0435\u0442 4\u043c\u043a\u0441. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0436\u0430\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u043a\u043e\u043b\u043e 250\u043a\u0411\u0430\u0439\u0442\/c, \u0438 \u044d\u0442\u043e \u043f\u0440\u0438 \u043a\u0432\u0430\u0440\u0446\u0435 \u043d\u0430 8\u041c\u0413\u0446.<br \/>\n<iframe loading=\"lazy\" width=\"420\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/SKAzoolWkNo\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0431\u0430\u0439\u0442\u0430 \u043f\u043e UART, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u043d\u0430 \u041f\u041a. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u043a \u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u0438\u0442\u044c AVR \u0438 \u041f\u041b\u0418\u0421.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[12,103,105,47],"class_list":["post-2823","post","type-post","status-publish","format-standard","hentry","category-fpga","tag-avr","tag-cpld","tag-fpga-2","tag-spi"],"_links":{"self":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/2823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2823"}],"version-history":[{"count":13,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/2823\/revisions"}],"predecessor-version":[{"id":5472,"href":"https:\/\/avr-start.ru\/index.php?rest_route=\/wp\/v2\/posts\/2823\/revisions\/5472"}],"wp:attachment":[{"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avr-start.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}