{"id":2570,"date":"2019-06-03T08:30:47","date_gmt":"2019-06-03T08:30:47","guid":{"rendered":""},"modified":"2019-06-03T16:31:02","modified_gmt":"2019-06-03T08:31:02","slug":"avr%e5%8d%95%e7%89%87%e6%9c%ba%e4%b8%8ecpld%e7%9a%84%e9%80%9a%e4%bf%a1%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2570","title":{"rendered":"AVR\u5355\u7247\u673a\u4e0eCPLD\u7684\u901a\u4fe1\u8bbe\u8ba1"},"content":{"rendered":"
\n\t\u9879\u76ee\u4e2d\u9700\u8981\u4f7f\u7528CPLD<\/u>\u5b8c\u6210\u4e00\u90e8\u5206\u7b97\u6cd5\u8bbe\u8ba1\uff0c\u53c2\u6570\u7531AVR<\/u>\u7ed9\u51fa\uff0c\u56e0\u6b64\u9700\u8981\u5b8c\u6210AVR\u548cCPLD\u7684\u901a\u4fe1\u3002\u56e0\u6b64\u5199\u4e86\u4e00\u4e2a\u6d4b\u8bd5<\/u>\u7a0b\u5e8f\u3002CPLD\u6302\u5728AVR\u7684\u6570\u636e\u548c\u5730\u5740\u603b\u7ebf\u4e0a\uff0cAVR\u4f7f\u7528ATmega128\uff0c\u5728CPLD\u4e2d\u8bbe\u7f6e\u51e0\u4e2a\u5bc4\u5b58\u5668<\/u>\uff0c\u901a\u8fc7AVR\u8bfb\u5199\u5bc4\u5b58\u5668\u6765\u5b9e\u73b0\u4e24\u8005\u4e4b\u95f4\u7684\u901a\u4fe1\u3002<\/p>\n
\n\tMega128\u7684\u5916\u90e8\u5b58\u50a8\u7a7a\u95f4\u4ece0X1100\u5f00\u59cb\uff0c\u56e0\u6b64\u53ea\u9700\u8981\u914d\u7f6e\u76f8\u5e94\u7684\u5bc4\u5b58\u5668\u540e\u8bfb\u53d6\u6216\u8005\u5199\u5165\u76f8\u5e94\u7684\u5730\u5740\u5c31\u53ef\u4ee5\uff0c\u7a0b\u5e8f\u6bd4\u8f83\u7b80\u5355\uff0c\u6ce8\u91ca\u4e2d\u90fd\u6709\u8bf4\u660e\uff0c\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n
\n\t\u529f\u80fd\uff1a\u6d4b\u8bd5AVR\u4e0eCPLD\u7684\u901a\u4fe1\uff0c\u5c06\u6570\u636e\u5199\u5165CPLD\u4e2d\u914d\u7f6e\u7684\u5bc4\u5b58\u5668\uff0c\u7136\u540e\u8bfb\u51fa\uff0c\u901a\u8fc7\u4e32\u53e3\u8f93\u51fa\u505a\u6bd4\u8f83\u3002<\/span><\/p>\n \n\t \n\t\/#include“avr\/io.h”<\/p>\n \n\t#include“avr\/inte<\/u>rrupt.h”<\/p>\n \n\t#include“uti<\/u>l\/delay.h”<\/p>\n \n\t#defineSetBit\uff08Port\uff0cN\uff09\uff08Port|=\uff081\u300a<\/p>\n \n\t#defineClrBit\uff08Port\uff0cN\uff09\uff08Port&=~\uff081\u300a<\/p>\n \n\t#defineReverBit\uff08Port\uff0cN\uff09\uff08Port^=\uff081\u300a<\/p>\n \n\t#defineGetBit\uff08Pi<\/u>n\uff0cN\uff09\uff08\uff08Pin\u300b\u300bN\uff09&0x01\uff09\/\/\u8bfb\u53d6IO\u67d0\u4e00\u4f4d<\/p>\n \n\tunsignedchardata;<\/p>\n \n\tvoidXRAM<\/u>_example\uff08void\uff09<\/p>\n \n\t{<\/p>\n \n\tunsignedchar*q=0x1100;\/\/\u5bc4\u5b58\u56681<\/p>\n \n\tunsignedchar*m=0x1101;\/\/\u5bc4\u5b58\u56682<\/p>\n \n\tunsignedchar*p=0x1102;\/\/\u5bc4\u5b58\u56683<\/p>\n \n\tPORTD=0XFF;<\/p>\n \n\tDDRD=0XFF;<\/p>\n \n\tDDRC=0xFF;\/\/\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u7aef\u53e3C\u7528\u505a\u9ad8\u5730\u5740\uff0c\u53ef\u4ee5\u6bcf\u53ea\u5bc4\u5b58\u5668\u628a\u7aef\u53e3C\u91ca\u653e<\/p>\n \n\tPORTC=0x00;<\/p>\n \n\t*q=0xCC;\/\/\u5411\u5bc4\u5b58\u56681\u4e2d\u5199\u5165\u6570\u636e\uff0cCPLD\u4e2d\u81ea\u52a8\u5c06\u5bc4\u5b58\u56681\u7684\u503c\u4ed8\u7ed9\u5bc4\u5b58\u56683<\/p>\n \n\tdata=*p;\/\/\u72ec\u5904\u5bc4\u5b58\u56683\u4e2d\u7684\u503c\uff0c\u5728\u5faa\u73af\u4e2d\u7528\u4e32\u53e3\u8f93\u51fa<\/p>\n \n\t}<\/p>\n \n\tvoidUSART0_Init\uff08void\uff09<\/p>\n \n\t{<\/p>\n \n\tUCSR<\/u>0A=0x20;\/\/\u6ce2\u7279\u7387\u4e0d\u52a0\u500d\uff0c\u5355\u673a\u901a\u4fe1\u6a21\u5f0f<\/p>\n \n\tUCSR0B=0x18;\/\/\u4e2d\u65ad\u4e0d\u4f7f\u80fd\uff0c\u5141\u8bb8\u53d1\u9001\u548c\u63a5\u6536<\/p>\n \n\tUCSR0C=0x06;\/\/\u5f02\u6b65\u6a21\u5f0f\uff0c\u65e0\u6821\u9a8c\uff0c8\u4f4d\u6570\u636e\uff0c1\u4f4d\u505c\u6b62\u4f4d<\/p>\n \n\tUBRR0H=0x00;<\/p>\n \n\tUBRR0L=51;\/\/9600\u6ce2\u7279\u7387\u6676\u632f8M<\/p>\n \n\t}<\/p>\n \n\tvoidUSART0_SendByte\uff08unsignedchardata\uff09<\/p>\n \n\t{<\/p>\n \n\twhile\uff08\uff01\uff08UCSR0A&\uff081\u300a<\/p>\n \n\tUDR0=data;\/\/\u53d1\u9001\u6570\u636e<\/p>\n \n\t}<\/p>\n \n\tintmai<\/u>n\uff08void\uff09<\/p>\n \n\t{<\/p>\n \n\tunsignedchari=0;<\/p>\n \n\tUSART0_Init\uff08\uff09;\/\/\u521d\u59cb\u5316USART0\u63a5\u53e3<\/p>\n \n\tMCU<\/u>CR=0xC0;\/\/\u4f7f\u80fd\u5916\u90e8SRAM<\/p>\n \n\tXMCRA=0x00;<\/p>\n \n\tDDRA=0XFF;<\/p>\n \n\tPORTA=0XFF;<\/p>\n \n\tDDRE=0xff;<\/p>\n \n\tDDRD=0xff;<\/p>\n \n\tPORTD=0x00;\/\/\u4f7f\u80fdCSA16A17=11<\/p>\n \n\tUSART0_SendByte\uff080x88\uff09;<\/p>\n \n\twhile\uff081\uff09<\/p>\n \n\t{<\/p>\n \n\tReverBit\uff08PORTA\uff0c0\uff09;<\/p>\n \n\tXRAM_example\uff08\uff09;<\/p>\n \n\t_delay_ms\uff08500\uff09;<\/p>\n \n\tUSART0_SendByte\uff08data\uff09;<\/p>\n \n\t}<\/p>\n \n\t}<\/p>\n","protected":false},"excerpt":{"rendered":" \u9879\u76ee\u4e2d\u9700\u8981\u4f7f\u7528 CPLD \u5b8c\u6210\u4e00\u90e8\u5206\u7b97\u6cd5\u8bbe\u8ba1\uff0c\u53c2\u6570\u7531A VR \u7ed9\u51fa\uff0c\u56e0\u6b64\u9700\u8981\u5b8c\u6210AVR\u548cCPLD\u7684\u901a\u4fe1\u3002\u56e0\u6b64\u5199\u4e86\u4e00\u4e2a \u6d4b\u8bd5 \u7a0b\u5e8f\u3002CPLD\u6302\u5728AVR\u7684\u6570\u636e\u548c\u5730\u5740\u603b\u7ebf\u4e0a\uff0cAVR\u4f7f\u7528ATmega128\uff0c\u5728CPLD\u4e2d\u8bbe\u7f6e\u51e0\u4e2a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2570"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2570"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2570\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2570"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\n\t<\/p>\n