{"id":2844,"date":"2019-10-07T06:58:53","date_gmt":"2019-10-07T06:58:53","guid":{"rendered":""},"modified":"2019-10-07T14:59:09","modified_gmt":"2019-10-07T06:59:09","slug":"lpc2138%e7%9a%84%e4%b8%b2%e5%8f%a3%e4%b8%ad%e6%96%ad%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2844","title":{"rendered":"LPC2138\u7684\u4e32\u53e3\u4e2d\u65ad\u7a0b\u5e8f\u8bbe\u8ba1"},"content":{"rendered":"
\n\tLPC<\/u>2138\u7684\u4e32\u53e3\u5e26\u670916\u5b57\u8282\u7684\u63a5\u6536\u548c\u53d1\u9001FIF<\/u>O\uff0c\u5e76\u4e14\u63a5\u6536FIFO\u7684\u89e6\u53d1\u70b9\u53ef\u8bbe\u4e3a1\uff0c4\uff0c8\uff0c14\u5b57\u8282\u3002<\/p>\n
\n\t1\uff09\u63a5\u6536<\/p>\n
\n\t\u5f53\u63a5\u6536\u5230\u7684\u5b57\u8282\u6570\u8fbe\u5230\u8bbe\u7f6e\u7684\u89e6\u53d1\u70b9\uff08\u901a\u8fc7FCR\u5bc4\u5b58\u5668<\/u>\u8bbe\u7f6e\uff09\u65f6\uff0c\u5c31\u4f1a\u4ea7\u751f\u63a5\u6536\u4e2d\u65ad\uff1b\u800c\u5f53\u63a5\u6536\u5230\u7684\u5b57\u8282\u6570\u672a\u80fd\u8fbe\u5230\u8bbe\u7f6e\u7684\u89e6\u53d1\u70b9\uff08\u6bd4\u5982\u89e6\u53d1\u70b9\u8bbe\u7f6e\u4e3a14\uff0c\u4f46\u662f\u53ea\u63a5\u6536\u5230\u4e8610\u4e2a\u5b57\u8282\u7684\u6570\u636e\uff09\uff0c\u90a3\u4e48\u7ecf\u8fc7\u77ed\u6682\u7684\u7b49\u5f85\u65f6\u95f4\u540e\u4f1a\u4ea7\u751f\u8d85\u65f6\u4e2d\u65ad\u3002\u5728\u8fd9\u4e24\u79cd\u60c5\u51b5\u4e0b\u9700\u8981\u6b63\u786e\u8bfb\u53d6RBR\u5bc4\u5b58\u5668\uff0c\u59a5\u5584\u4fdd\u5b58\u63a5\u6536\u5230\u7684\u6570\u636e\u3002
\n\t \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5047\u8bbe\u63a5\u6536FIFO\u7684\u89e6\u53d1\u70b9\u8bbe\u7f6e\u4e3a14\uff0c\u800c\u8981\u63a5\u6536\u7684\u6570\u636e\u4e00\u5171\u670916\u5b57\u8282\u3002\u90a3\u4e48\u63a5\u6536\u8fc7\u7a0b\u4e2d\u4f1a\u4ea7\u751f\u4e24\u6b21\u4e2d\u65ad\uff1a\u7b2c\u4e00\u6b21\u662f\u5f53\u63a5\u6536\u5230\u7b2c14\u4e2a\u5b57\u8282\u65f6\u4ea7\u751f\u7684\u63a5\u6536\u4e2d\u65ad\uff1b\u4e4b\u540e\u53ea\u52692\u4e2a\u5b57\u8282\u8981\u63a5\u6536\uff0c\u8fbe\u4e0d\u5230\u89e6\u53d1\u70b914\uff0c\u6240\u4ee5\u7ecf\u8fc7\u7b49\u5f85\u65f6\u95f4\u540e\u4f1a\u4ea7\u751f\u8d85\u65f6\u4e2d\u65ad\u3002
\n\t \u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f\u91cc\uff0c\u5bf9\u4e8e\u8fd9\u4e24\u79cd\u4e2d\u65ad\u53ef\u8fdb\u884c\u5982\u4e0b\u7684\u5904\u7406\uff08\u5047\u8bbe\u4f7f\u7528UART<\/u>1\uff09\uff1a<\/p>\n
\n\t
\n\t<\/p>\n
\n\tswitch (U1IIR & 0x0E)
\n\t {
\n\t case 0x0C: \/\/ \u82e5\u4e3a\u8d85\u65f6\u4e2d\u65ad\uff08\u6ce8\u610f\u6b64\u5904\u4e0d\u8981\u52a0break\uff09
\n\t case 0x04: \/\/ \u82e5\u4e3a\u63a5\u6536\u4e2d\u65ad
\n\t while ((U1LSR & 0x01) == 1) \/\/ \u82e5U1RBR\u5305\u542b\u6709\u6548\u6570\u636e
\n\t Rec_Buffer[index++] = U1RBR; \/\/ \u4fdd\u5b58\u63a5\u6536\u5230\u7684\u6570\u636e
\n\t }<\/p>\n
\n\t
\n\t 2\uff09\u53d1\u9001<\/p>\n
\n\t\u53d1\u9001FIFO\u5e76\u6ca1\u6709\u89e6\u53d1\u70b9\u7684\u95ee\u9898\u3002\u8981\u53d1\u9001\u6570\u636e\u65f6\uff0c\u9996\u5148\u628a\u6570\u636e\u5199\u5165THR\u5bc4\u5b58\u5668\uff0c\u4e4b\u540eMCU<\/u>\u4f1a\u5c06\u5176\u79fb\u5165\u53d1\u9001FIFO\u7f13\u51b2\u533a\u4e2d\uff0c\u4e00\u65e6THR\u5bc4\u5b58\u5668\u88ab\u79fb\u7a7a\uff0c\u5c31\u4f1a\u4ea7\u751f\u53d1\u9001\u4e2d\u65ad\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5728\u4f7f\u80fd\u4e86\u53d1\u9001\u4e2d\u65ad\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u5411THR\u5bc4\u5b58\u5668\u5199\u4e00\u4e2a\u5b57\u8282\u5c31\u4f1a\u5f15\u8d77\u4e00\u6b21\u53d1\u9001\u4e2d\u65ad\u3002\u6240\u4ee5\u8981\u53d1\u9001\u4e00\u7cfb\u5217\u7684\u6570\u636e\u65f6\uff0c\u53ea\u9700\u8981\u53d1\u9001\u7b2c\u4e00\u4e2a\u5b57\u8282\u6765\u542f\u52a8\u53d1\u9001\u8fc7\u7a0b\uff0c\u5269\u4f59\u7684\u5b57\u8282\u7531\u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f\u6765\u5b8c\u6210\u5c31\u53ef\u4ee5\u4e86\u3002
\n\t \u5047\u8bbeSend_Length\u4e3a\u8981\u53d1\u9001\u7684\u603b\u5b57\u8282\u6570\uff0c\u7a0b\u5e8f\u4e2d\u7684\u5904\u7406\u5982\u4e0b\uff1a<\/p>\n
\n\t
\n\t U1THR = Txd_Buffer[0];
\n\t index = 1;
\n\t
\n\t void __irq Uart1_isp(void) \/\/ \u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f
\n\t {
\n\t if ((U1IIR & 0x0E) == 0x02) \/\/ \u5224\u65ad\u662f\u5426\u4e3a\u53d1\u9001\u4e2d\u65ad
\n\t {
\n\t if (index != Send_Length)
\n\t {
\n\t U1THR = Txd_Buffer[index];
\n\t index ++;
\n\t }
\n\t }
\n\t }<\/p>\n
\n\t
\n\t \u4e2a\u4eba\u89c9\u5f97\uff0c\u4f7f\u80fd\u53d1\u9001\u4e2d\u65ad\u4f1a\u5bfc\u81f4MCU\u7684\u5de5\u4f5c\u6548\u7387\u53d8\u4f4e\u3002\u56e0\u4e3a\u4e00\u65e6THR\u5bc4\u5b58\u5668\u4e3a\u7a7a\u5c31\u4f1a\u8fdb\u5165\u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f\uff0c\u4f1a\u51fa\u73b0\u8fde\u7eed\u7684\u65e0\u6548\u4e2d\u65ad\u3002\uff08\u5982\u679c\u7406\u89e3\u6709\u9519\u8bef\uff0c\u8fd8\u8bf7\u6307\u6b63\uff09
\n\t \u5728\u4e0d\u4f7f\u80fd\u53d1\u9001\u4e2d\u65ad\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u7528\u67e5\u8be2\u65b9\u5f0f\u5b9e\u73b0\u4ee5\u4e0a\u7684\u53d1\u9001\u8fc7\u7a0b\uff1a<\/p>\n
\n\t
\n\t int i;
\n\t for (i = 0; i < Send_Length; i++)
\n\t {
\n\t U1THR = Txd_Buffer[i];
\n\t while (!(U1LSR & 0x20)); \/\/ \u7b49\u5f85\u5f53\u524d\u5b57\u8282\u53d1\u9001\u5b8c\u6bd5
\n\t }
\n\t\u6765\u6e90\uff1b\u7535\u5b50\u5de5\u7a0b\u7f51<\/p>\n","protected":false},"excerpt":{"rendered":"
LPC 2138\u7684\u4e32\u53e3\u5e26\u670916\u5b57\u8282\u7684\u63a5\u6536\u548c\u53d1\u9001F IF O\uff0c\u5e76\u4e14\u63a5\u6536FIFO\u7684\u89e6\u53d1\u70b9\u53ef\u8bbe\u4e3a1\uff0c4\uff0c8\uff0c14\u5b57\u8282\u3002 1\uff09\u63a5\u6536 \u5f53\u63a5\u6536\u5230\u7684\u5b57\u8282\u6570\u8fbe\u5230\u8bbe\u7f6e\u7684\u89e6\u53d1\u70b9\uff08\u901a\u8fc7FCR \u5bc4\u5b58\u5668 \u8bbe\u7f6e\uff09\u65f6\uff0c\u5c31\u4f1a\u4ea7\u751f\u63a5\u6536\u4e2d\u65ad\uff1b<\/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\/2844"}],"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=2844"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2844\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2844"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}