{"id":369,"date":"2021-02-15T18:26:52","date_gmt":"2021-02-15T09:26:52","guid":{"rendered":"https:\/\/www.ekit-tech.com\/?p=369"},"modified":"2024-01-26T12:40:27","modified_gmt":"2024-01-26T03:40:27","slug":"pic12f1822%e3%81%a7lcd%e3%83%87%e3%82%a3%e3%82%b9%e3%83%97%e3%83%ac%e3%82%a4%ef%bc%88ae-aqm1602a%ef%bc%89%e3%82%92%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aa","status":"publish","type":"post","link":"https:\/\/www.ekit-tech.com\/?p=369","title":{"rendered":"PIC12F1822\u3067LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\uff08AE-AQM1602A\uff09\u3092\u8868\u793a\u3059\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02.jpg\"><img loading=\"lazy\" width=\"1200\" height=\"800\" src=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02.jpg\" alt=\"PIC12F1822\u3067LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\uff08AE-AQM1602A\uff09\u3092\u8868\u793a\" class=\"wp-image-370\" srcset=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02.jpg 1200w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02-300x200.jpg 300w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02-768x512.jpg 768w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-02-1024x683.jpg 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n\n\n\n<p>\u79cb\u6708\u96fb\u5b50\u3067\u4ee5\u4e0b\u306eLCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3092\u8cfc\u5165\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/akizukidenshi.com\/catalog\/g\/g108896\">I2c\u63a5\u7d9a\u5c0f\u578b\u30ad\u30e3\u30e9\u30af\u30bfLCD\u30e2\u30b8\u30e5\u30fc\u30eb\uff0816\u00d72\u884c\u30fb3.3\uff36\/5\uff36\uff09\u30d4\u30c3\u30c1\u5909\u63db\u30ad\u30c3\u30c8 AE-AQM1602A\uff08KIT\uff09<\/a><\/p>\n\n\n\n<p class=\"sp2\">\u4eca\u56de\u306f\u3001PIC12F1822\u3092\u4f7f\u3063\u3066\u3001\u3053\u306eLCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306b\u6587\u5b57\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u30c6\u30b9\u30c8\u7528\u306b\u30b7\u30f3\u30d7\u30eb\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<\/div><h2>\u56de\u8def\u56f3<\/h2><div class=\"inner\">\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01.jpg\"><img loading=\"lazy\" width=\"1200\" height=\"800\" src=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01.jpg\" alt=\"PIC12F1822\u3067LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\uff08AE-AQM1602A\uff09\u3092\u8868\u793a\u3059\u308b\u96fb\u5b50\u56de\u8def\" class=\"wp-image-374\" srcset=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01.jpg 1200w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01-300x200.jpg 300w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01-768x512.jpg 768w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-01-1024x683.jpg 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n\n\n\n<p>\u203bSDA\u30fbSCL\u30e9\u30a4\u30f3\u306e10K\u03a9\u62b5\u6297\u306f\u3001\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3067\u5fc5\u8981\u306a\u30d7\u30eb\u30a2\u30c3\u30d7\u62b5\u6297\u3067\u3059\u3002<\/p>\n\n\n\n<\/div><h2>\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2><div class=\"inner\">\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n * \n *  PIC12F1822\n *  \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3067LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3078\uff08AE-AQM1602A\uff09\u8868\u793a\n *                                   - 2021\/02\/15 -\n * \n *\/\n\/\/\u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\n\/\/--------------------------------------------------------------\n#include &lt;xc.h&gt;\n#include &lt;stdio.h&gt;  \/\/ printf\u3092\u4f7f\u3046\u305f\u3081\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\n\/\/ \u30af\u30ed\u30c3\u30af\u5468\u6ce2\u6570\u6307\u5b9a\n\/\/--------------------------------------------------------------\n#define _XTAL_FREQ 32000000\n\/\/ LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\uff08AE-AQM1602A\uff09\u306e\u30a2\u30c9\u30ec\u30b9\n\/\/--------------------------------------------------------------\n#define LCD_addr 0x7C\n\/\/ \u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u5ba3\u8a00\n\/\/--------------------------------------------------------------\nvoid I2C_init(void);\nvoid I2C_start(void);\nvoid I2C_stop(void);\nvoid I2C_write(unsigned char dat);\nvoid LCD_cmd(unsigned char cmd);\nvoid LCD_char(unsigned char dat);\nvoid LCD_init(void);\nvoid LCD_clear(void);\nvoid LCD_home(void);\nvoid LCD_cursor(unsigned x,unsigned y);\n\/\/ ============================================================\n\/\/\n\/\/                \u3000 \u30e1\u30a4\u30f3\u30d7\u30ed\u30b0\u30e9\u30e0\n\/\/\n\/\/ ============================================================\n\/*\u3000\u3000 \u3000\u3000\u3000\u3000\u3000    \u3000 12F1822\n *                   \uff0d\uff0d\uff0d\uff0d\uff0d\uff0d        \n *             VDD \uff0d| 1      8 |\uff0d VSS\n *             RA5 \uff0d| 2      7 |\uff0d AN0\/RA0\n *         AN3\/RA4 \uff0d| 3      6 |\uff0d AN1\/RA1\/SCL \u2192 LCD(SCL)\n *             RA3 \uff0d| 4      5 |\uff0d AN2\/RA2\/SDA \u2192 LCD(SDA)\n *                   \uff0d\uff0d\uff0d\uff0d\uff0d\uff0d      \n *\/\nvoid main() {\n    \n    \/\/----------------------------------------------------------\n    \/\/               PIC\u30de\u30a4\u30b3\u30f3\u521d\u671f\u8a2d\u5b9a\n    \/\/----------------------------------------------------------\n    OSCCON = 0b01110000;    \/\/ \u5185\u90e8\u30af\u30ed\u30c3\u30af\u5468\u6ce2\u6570\uff1a8MHz\n    ANSELA = 0b00000000;    \/\/ \u5168\u3066\u30c7\u30b8\u30bf\u30eb\u30e2\u30fc\u30c9\n    TRISA  = 0b00000110;    \/\/ SCL[6Pin]\u3001SDA[5Pin]\u3092\u5165\u529b\u30d4\u30f3\u306b\u8a2d\u5b9a\n    \n    \/\/----------------------------------------------------------\n    \/\/            \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\uff08I2C\uff09\u521d\u671f\u8a2d\u5b9a\n    \/\/----------------------------------------------------------\n    SSP1STAT = 0b10000000;  \/\/ \u6a19\u6e96\u30e2\u30fc\u30c9(100kHz)\n    SSP1CON1 = 0b00101000;  \/\/ \u30de\u30b9\u30bf\u30fc\uff08\u5236\u5fa1\u3059\u308b\u5074\uff09\u306b\u8a2d\u5b9a\n    SSP1ADD = 0b01001111;   \/\/ \u901a\u4fe1\u901f\u5ea6 = Fosc\/(4*Clock)-1 = 32MHz\/(4*100kHz)-1 = 79\uff0810\u9032\u6570\uff09\n    \n     \/\/----------------------------------------------------------\n    \/\/              LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3068\u901a\u4fe1\n    \/\/----------------------------------------------------------\n    \n    \/\/ \u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u521d\u671f\u5316\n    LCD_init();\n       \n    \/\/ \uff11\u5217\u76ee\u306b\u8868\u793a\n    LCD_cmd(0x80);\n    printf(\"Hello World!\");\n    \/\/ \uff12\u5217\u76ee\u306b\u8868\u793a\n    LCD_cmd(0xC0);\n    printf(\"0123456789\");\n    \n}\n\/\/ ============================================================\n\/\/\n\/\/                \u3000    I2C \u901a\u4fe1\u958b\u59cb\n\/\/\n\/\/ ============================================================\nvoid I2C_start() {\n    SEN = 1;\n    while(SEN);\n}\n\/\/ ============================================================\n\/\/\n\/\/                \u3000    I2C \u901a\u4fe1\u7d42\u4e86\n\/\/\n\/\/ ============================================================\nvoid I2C_stop() {\n    SSP1IF = 0;\n    PEN = 1;\n    while(PEN);\n    SSP1IF = 0;\n}\n\/\/ ============================================================\n\/\/\n\/\/                \u3000   I2C \u30c7\u30fc\u30bf\u9001\u4fe1\n\/\/\n\/\/ ============================================================\nvoid I2C_write(unsigned char dat) {\n    SSP1IF = 0;\n    SSP1BUF = dat;\n    while(!SSP1IF);\n}\n\/\/ ============================================================\n\/\/\n\/\/           \u3000LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u521d\u671f\u5316\n\/\/\n\/\/ ============================================================\nvoid LCD_init() {\n    __delay_ms(40); \/\/40ms wait\n    LCD_cmd(0x38);  \/\/8bit,2line\n    LCD_cmd(0x39);  \/\/IS=1 : extention mode set\n    LCD_cmd(0x14);  \/\/Internal OSC Frequency\n    LCD_cmd(0x7A);  \/\/Contrast set\n    LCD_cmd(0x56);  \/\/Power\/ICON\/Contrast Control\n    LCD_cmd(0x6C);  \/\/Follower control\n    __delay_ms(200);\/\/200ms wait\n    LCD_cmd(0x38);  \/\/IS=0 : extention mode cancel\n    LCD_cmd(0x0C);  \/\/Display ON\n    LCD_cmd(0x01);  \/\/Clear Display\n    __delay_ms(2);  \/\/wait more than 1.08ms\n}\n\/\/ ============================================================\n\/\/\n\/\/                   LCD\u3078\u30b3\u30de\u30f3\u30c9\u3092\u9001\u4fe1\n\/\/\n\/\/ ============================================================\nvoid LCD_cmd(unsigned char cmd) {\n    I2C_start();\n    I2C_write(LCD_addr);\n    I2C_write(0x00);    \/\/ 0x00\uff08\u30b3\u30de\u30f3\u30c9\u306e\u9001\u4fe1\u3092\u793a\u3059bit\uff09\n    I2C_write(cmd);\n    I2C_stop();\n}\n\/\/ ============================================================\n\/\/\n\/\/              LCD\u3078\u8868\u793a\u3059\u308b\u30c7\u30fc\u30bf\u306e\u9001\u4fe1\n\/\/        printf\u6587\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306bputch\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\n\/\/\n\/\/ ============================================================\nvoid putch(unsigned char text) {\n    I2C_start();\n    I2C_write(LCD_addr);\n    I2C_write(0x40);    \/\/ 0x40\uff08\u30c7\u30fc\u30bf\u306e\u9001\u4fe1\u3092\u793a\u3059bit\uff09\n    I2C_write(text);\n    I2C_stop(); \n}<\/stdio.h><\/xc.h><\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/lcd_test.txt\">lcd_test.txt<\/a><\/p>\n\n\n\n<p class=\"sp2\">\u203bLCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306b\u6587\u5b57\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u3001\u300cprintf\u6587\u300d\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"sp2\">printf\u6587\u3092\u4f7f\u7528\u3059\u308b\u969b\u306f\u3001<\/p>\n\n\n\n<p>12\u884c\u76ee\uff1astdio.h\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30af\u30eb\u30fc\u30c9<\/p>\n\n\n\n<p>149\u884c\u76ee\uff1aputch\u95a2\u6570<\/p>\n\n\n\n<p>\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"sp2\">\u307e\u305f\u3001printf\u6587\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u6307\u5b9a\u5b50\u3092\u4f7f\u3046\u3068\u3001PIC12F1822\u3067\u306f\u30e1\u30e2\u30ea\u4e0d\u8db3\u3068\u306a\u308a\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4f8b\uff1aprintf(&#8220;%3d&#8221;,count);<\/p>\n\n\n\n<p>\u300c%3d\u300d\u306e\u90e8\u5206\u304c\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u6307\u5b9a\u5b50\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"sp2\">\u3061\u306a\u307f\u306b\u3001printf\u6587\u3092\u4f7f\u7528\u305b\u305a\u306bLCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306b\u6587\u5b57\u3092\u8868\u793a\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u8aac\u660e\u66f8\u306b\u63b2\u8f09\u3055\u308c\u3066\u3044\u308b\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u3092\u898b\u306a\u304c\u3089\u3001\u30d3\u30c3\u30c8\u3067\u9001\u3089\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u304b\u3089\u5927\u5909\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03.jpg\"><img loading=\"lazy\" width=\"1200\" height=\"800\" src=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03.jpg\" alt=\"LCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u8868\" class=\"wp-image-393\" srcset=\"https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03.jpg 1200w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03-300x200.jpg 300w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03-768x512.jpg 768w, https:\/\/www.ekit-tech.com\/wp-content\/uploads\/20210215-03-1024x683.jpg 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u79cb\u6708\u96fb\u5b50\u3067\u4ee5\u4e0b\u306eLCD\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3092\u8cfc\u5165\u3057\u307e\u3057\u305f\u3002 I2c\u63a5\u7d9a\u5c0f\u578b\u30ad\u30e3\u30e9\u30af\u30bfLCD\u30e2\u30b8\u30e5\u30fc\u30eb\uff0816\u00d72\u884c\u30fb3.3\uff36\/5\uff36\uff09\u30d4\u30c3\u30c1\u5909\u63db\u30ad\u30c3\u30c8 AE-AQM1602A\uff08KIT\uff09 \u4eca\u56de\u306f\u3001PIC12F1822\u3092\u4f7f\u3063\u3066\u3001\u3053\u306eLC [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":370,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[69,70],"_links":{"self":[{"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/369"}],"collection":[{"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=369"}],"version-history":[{"count":29,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/369\/revisions"}],"predecessor-version":[{"id":7496,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/posts\/369\/revisions\/7496"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=\/wp\/v2\/media\/370"}],"wp:attachment":[{"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ekit-tech.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}