å 責äºé ïŒ èè ã¯ããããã«ããŠãã圌ãã®ããã®æ°ããåéã§ã®çµéšäžè¶³ã®ããã究極ã®çå®ãä¿èšŒãããã®ã§ã¯ãããŸããã é倧ãªæè¡çãšã©ãŒãçºçããå Žåã¯ãã§ããã ãæ©ãå ±åããŠãã ããã
ã©ãããããããåå¿è ããã°ã©ããŒãšåå¿è ã®é»åæè¡è ã®éåœãçµã³ä»ããŸããã ãããŠã圌ãã¯åµé ãå§ããŸããã 圌ãã¯é²é³ã¢ãžã¥ãŒã«ã§æ°ååã®å°ããªããã£ãã¢ãäœããåæ©èœããŒãã䜿çšããã®ã¯ããã»ã©é¢çœããªãããšã«æ°ä»ããŸããã ãããŠãæããå€ã®å€ã«åœŒãã¯éãŸããäœããããªã«é¢çœããšæããŸãããïŒ éåœã¯åœŒãã«2床ç®ã®å©ããããŸããã圌ãã¯ãã·ã¢ã§STM32VLDiscoveryãããã°ããŒãã®è²©å£²ã®åºåãèŠã€ãã1é±éåŸã«æ¡æãããŠLEDããç¹æ» ããããŠããã±ãŒãžãé梱ããŸããã å°ããªããã€ã¹ã«å¯Ÿããå®å šãªåã®æèŠã¯åœŒã®ç®ã«ç«ãã€ããè³ãç²åŸããŸããã æ°ãããããã¡ããã®å¯èœæ§ãæ倧éã«æŽ»çšããŠãèå³æ·±ãæ©èœãåãããé»åãã¬ã¹ã¬ããããäœãããšã決å®ãããŸãã...
STM32ã®äœ¿çšæ¹æ³ã«ã€ããŠåŠç¿ãããšãã圌ã®ç®ã¯ããã«æãããªããŸããã ãŸããããããçš®é¡ã®åšèŸºæ©åšãæ¥ç¶ããããšãèããŸããã ç§ãã¡ã®æã«ã¯ããœããšãæèšã®7ã»ã°ã¡ã³ãLCDããããŸããã æ¥ç¶ããŠã¿ã€ããŒãäœæããŸããããèœã¡çããŸããã§ãã...
ç¿æ¥ãç§ãã¡ã¯ãµãŒãã¹ã»ã³ã¿ãŒã®å°ããªåºã«å ¥ããèšå€§ãªæ°ã®è§£æããé»è©±ã«dç¶ãšããŸãããéå»æ°å¹Žã®æºåž¯é»è©±ã®ããŸããŸãªãããããã§å®å šã«æºãããã3å°ã®ã¹ã¿ã³ãã ããã80ã«ãŒãã«ã®å Žåãã·ãŒã¡ã³ã¹C55ãè³Œå ¥ãããåŸã«ç§ãã¡ã®ãããŒã«ãªããŸããã
ã±ãŒã¹ãéããŠã ITãåŸãŸããã解å床ã102 x 64ãã¯ã»ã«ã®ã¢ãã¯ãLPH7999-4 LCDã¹ã¯ãªãŒã³ã§ãã å®éã«ã¯ãLCDãããªãã¯ã¹ãšPCF8812ã³ã³ãããŒã©ãŒã§æ§æãããŠããŸãïŒããŒã¿ã·ãŒããžã®ãªã³ã¯ïŒ ã ã³ã³ãããŒã©ãŒã¯DDRAMã§æ§æããããã¯ã»ã«ïŒ1 \ 0ïŒã®ç¶æ ãI \ Oãããã¡ãŒãè€æ°ã®é»æµãžã§ãã¬ãŒã¿ãŒãããã³è«çèŠçŽ ããããåäœã§ããŒãã«ã«ä¿åãããŸãã LCDã䜿çšãããã¹ãŠã®ã¢ã¯ã·ã§ã³ã¯ãVDDãSCKãMISOãDCãSSãGNDãVOUTãRESã®8æ¬ã®èãä»ããŠã³ã³ãããŒã©ãŒã䜿çšããŠçŽæ¥è¡ãããŸãããã®ãã¡2ã€ã¯ã³ã³ãã³ãµãä»ããŠéããæ®ãã¯ããã»ããµã®èã«æ¥ç¶ããŸãã
åæã«ãããããã¯ã©ã®ãããªãããŸããªæå®ã§ããããããã©ã®ããã«å¶åŸ¡ã§ããã®ã§ããããïŒã å®å šãªæ²ãã¿ãšçµ¶ææã®è¡šçŸã§ãç§ãã¡ã¯ã°ãŒã°ã«ãå§ããæªç¥ã®çšèªã§ãã£ã±ãã®èšäºã«çµ¶ããã¶ã€ãããŸããã ãã®çµæãç§ãã¡ã®é ã®äžã§æ°æ¥åŸãå°ãæ°ããæ å ±ãã¬ã€ã¢ãŠããããŸããã
MOSIïŒãŸãã¯SIMOãSDOãDOãDOUTãSOãMTSRïŒ
ãã¹ã¿ãŒåºåã¹ã¬ãŒãå ¥å | ãã¹ã¿ãŒåºåãã¹ã¬ãŒãå ¥åã«æ¥ç¶ããå¿ èŠããããŸã |
MISOïŒãŸãã¯SOMIãSDIãDIãDINãSIãMRSTïŒ
ãã¹ã¿ãŒå ¥åã¹ã¬ãŒãåºå | ã¹ã¬ãŒãåºåãäŸçµŠããããã¹ã¿ãŒå ¥å |
SCKïŒãŸãã¯SCLKãCLKïŒ
| MISO \ MOSIãããããã解æããããã«æäŸãããã¯ããã¯åšæ³¢æ° |
SSïŒãŸãã¯CSïŒ
| 䜿çšããåšèŸºæ©åšã®éžæã
è€æ°ã®ããã€ã¹ãããå Žåãç¹å®ã®ããã€ã¹ã§äœæ¥ããã«ã¯ãéžæããããã€ã¹ã®ãžã£ã³ããŒãããããªãã«ããä»ã®ãã¹ãŠã®ããã€ã¹ã§ãªã³ã«ããŸãã |
ãããã£ãŠãLCDãå¶åŸ¡ããã«ã¯ãåšèŸºæ©åšãšéä¿¡ããããã®æšæºåãããã€ã³ã¿ãŒãã§ã€ã¹ã§ããSPIã䜿çšããå¿ èŠããããŸãã ããã䜿çšããã«ã¯ãä»äºã®ååãšããã«é¢é£ãããã¹ãŠã®çšèªãç¹ã«ãã¹ãŠã®èã®ååãšç®çãç解ããå¿ èŠããããŸãã
SPIã€ã³ã¿ãŒãã§ãŒã¹ã¯ããã¹ãŠãå¶åŸ¡ãã1ã€ã®ããã€ã¹ïŒãã¹ã¿ãŒïŒãšãã»ã³ãµãŒãLCD \ LCDãã¡ã¢ãªã«ãŒããADC \ DACãªã©ã®å€ãã®å¶åŸ¡ãããåšèŸºæ©åšãããããšãåæãšããŠããŸãã ïŒå¥Žé·ïŒã ãã¹ã¿ãŒã§ã¯ãããŒã¿ã®åä¿¡/éä¿¡çšã«3ã€ã®ã¬ãã°ãšãnåã®ã¬ãã°ãžã£ã³ããŒãéžæããå¿ èŠããããŸããnã¯æ¥ç¶ãããåšèŸºæ©åšã®æ°ã§ãã ã¹ã¬ãŒãããã€ã¹ã§ã¯ãåä¿¡/éä¿¡ã®ã¬ãã°ã¯éåžžäºåã«å®çŸ©ããïŒãã¡ããããããå¥ã®ããã»ããµã§ãªãå ŽåïŒã察å¿ããããŒã¿ã·ãŒãã«èšèŒãããŠããŸãã
æœè±¡ãã¹ã¿ãŒãš1ã€ã®æœè±¡ã¹ã¬ãŒãããã€ã¹éã§ããŒã¿ãéåä¿¡ããæäœã®äŸãèŠãŠã¿ãŸãããã
æ³šïŒ SPIã¯æ¬¡ã®ããã«æ§æãããŠããŸããããŒã¿ãMOSIãã¹ã¿ãŒããMISOã¹ã¬ãŒãã«è»¢éããããšãããŒã¿ã¯MOSIã¹ã¬ãŒãããMISOãã¹ã¿ãŒã«åæã«è»¢éãããŸãã ãããã£ãŠãSCKä¿¡å·ã¯ããããMISOãšMOSIã§åãã§ãããåãããã«æ©èœããŸãã
1ãã€ããéä¿¡ããå ŽåãSCKããã³MOSIåºåãé¢ä¿ããŸãã SCKã¯ããã¯ãã«ã¹ãåºåããŸãïŒè«çãŒãããè«çãŠããããžã®é»å§éäžïŒã è«çãŠããããéä¿¡ããå Žåãåºåé»å§ã¯ã3.3VããŒããéä¿¡ããå Žåã¯ããããã0Vã§ãã è«çãŒãããã³è«çãŠãããã®ç¶æ ã®æéã¯çãããããã°ã©ã ã§èšå®ãããŸãã 1ãã€ããéä¿¡ãããšãåãããã«ã€ã³ãã«ã¹ãèœã¡ãŸãã ãããã£ãŠãSCKåºåããã€ã転éã§ã¯ã8ã€ã®åäžã®ããã³ãããèŠãããŸãã MOSIã®åºåã§ã¯ãæ å ±ãçŽæ¥éä¿¡ãããŸãã ããšãã°ã10000001ãéä¿¡ãããšãä¿¡å·ã¯å€§ããªç©Žã®ããã«èŠãã10011001ã®å Žåã¯ãäžå€®ã«çªèµ·ã®ããç©Žã®ããã«ãªããŸãã äž¡æ¹ã®åºåãåå¥ã«ã©ã®ããã«æ©èœããã®ãã¯æããã ãšæããŸããä»åºŠã¯ãããããäºãã«ã©ã®ããã«èª¿æŽããããã«ã€ããŠèª¬æããŸãã
ã¢ã€ãã«ã¢ãŒãã äœãéä¿¡ãããªãç¬éãã€ãŸãããã€ãã®éä¿¡ééãŸãã¯SPIããªã³ã«ãªã£ãŠããéä¿¡ã®éå§åã äž¡æ¹ã®å ¥åã«æäœããªãå Žåã¯0ã«ãªããšæ³å®ããã®ã¯è«ççã§ããããããã¢ã€ãã«ã¢ãŒãã§ã¯ãMOSIã®è«çãŠãããã®é»å§ãSCKã®é»å§ã¯è«çãŠããããŸãã¯ãŒãã§ãã ãã®SCKã®ç¶æ ã¯ãèªåã§éžæã§ããŸãã
éä¿¡ã¢ãŒãã ããã§ãSCKããŒããšMOSIããŒãã®ã€ã³ãã«ã¹ã®èª¿æŽæ¹æ³ãéžæããå¿ èŠããããŸãã ãããè¡ãã«ã¯ãããã€ãã®æªãèšèãå ¥åããå¿ èŠããããŸãã
åé¢ã¯ãããç¶æ ããå¥ã®ç¶æ ãžã®é·ç§»ãã€ãŸããè«çãŠãããããè«çãŒããžã®é»å§ãžã£ã³ãã§ãã ã€ã³ãã«ã¹ã®ã€ã¡ãŒãžã§ã¯ããããã¯åçŽã®æ£ã§ãã
æ£é¢ã¯äžæãšäžéã§ããäžæ-è«çãŒãããè«çãŠããããžã®ç§»è¡ãäžé-å察ã«ãè«çãŠãããããè«çãŒããžã®ç§»è¡ã
åéšãåéšãšåŸéšã§ããåéšåéšã¯ã¢ã€ãã«ã¢ãŒãåŸã«çºçããæåã®ãžã£ã³ãã§ãåŸéšåéšã¯ã¢ã€ãã«ã¢ãŒãåŸã«çºçãã2çªç®ã®ãžã£ã³ãã§ãã
éçºè ã¯ãSCKã¢ã€ãã«ã¢ãŒãïŒè«çãŠããããŸãã¯ãŒãïŒãšéä¿¡ã¢ãŒãïŒãªãŒãã£ã³ã°ãšããžãŸãã¯ãã¬ãŒãªã³ã°ãšããžïŒãéžæã§ããŸãã åèšã§ã4ã€ã®åäœã¢ãŒãããããŸãã
ã¢ãŒã0ïŒ00ïŒïŒ
ããŠã³ã¿ã€ã ã¯è«çãŒãã§ãã
ããã³ããšã³ãéä¿¡ã
SCKã§è«çãŒãé»å§ããè«çãŠãããé»å§ãžã®ç§»è¡äžã«ãªãŒãã£ã³ã°ãšããžéä¿¡ãéžæãããããMOSIã§ãããéä¿¡ãçºçããŸãã
ã¢ãŒã1ïŒ01ïŒïŒ
ããŠã³ã¿ã€ã ã¯è«çãŒãã§ãã
ãªããŒã¹ã®ã¢ã
ç«ã¡äžãããšããžã§éä¿¡ãéžæãããããæåã«ç«ã¡äžããã®ç«ã¡äžãããšããžãããã次ã«è«çãŒãé»å§ããã°ããä¿æããã次ã«ç«ã¡äžããã®ãšããžããããŸãã ãã®åŸãMOSIã§ãããéä¿¡ãè¡ãããŸãã
ã¢ãŒã2ïŒ10ïŒïŒ
ããŠã³ã¿ã€ã ã¯è«ççãªåäœã§ãã
ããã³ããšã³ãéä¿¡ã
éä¿¡äžãã€ã³ãã«ã¹ãSCKã«éãããŸãã ãã ããåã®2ã€ã®ã¢ãŒããšã¯ç°ãªããå¢å ããŠããŸããããæžå°ããŠããŸãã é»å§ã®è«çåäœãè¶ ããé»å§ã¯ãªããããæåã®ã€ã³ãã«ã¹ã¯ãããŠã³ãããŸãã ããããMOSIã«éä¿¡ãããã®ã¯ããã®ç§»è¡äžã§ãïŒçµå±ããªãŒãã£ã³ã°ãšããžãéžæããŸããïŒã
ã¢ãŒã3ïŒ11ïŒïŒ
ããŠã³ã¿ã€ã ã¯è«ççãªåäœã§ãã
ãªããŒã¹ã®ã¢ã
éä¿¡äžãSCKãžã®ã€ã³ãã«ã¹ããããæåã«äœäžããŠããå¢å ããŸãã çŸæç¹ã§ã¯ãMOSIãžã®ç§»è¡ããããŸãã
éåžžãåäœã¢ãŒãã¯ããŒã¿ã·ãŒãã«ç€ºãããŠããŸããããããŒã¿ã·ãŒãã®ãã£ãŒãã§MOSI \ MISOããã³SCKã®åäœã調ã¹ããšãç°¡åã«ååŸã§ããŸãã
ããã§ã¯ãã³ã³ãããŒã©ãŒã§äœãå¶åŸ¡ã§ããŸããïŒ
ãŸããã³ã³ãããŒã©ãŒãLCDãããªãã¯ã¹ã«è¡šç€ºããã¡ã¢ãªãŒããããŸãã
第äºã«ã座æšXãšYãæã€ã¡ã¢ãªãã£ãªããžããããŸãã
第äžã«ãäœåãã®ç°ãªããããããããŸãã
PDããã-0ã®å Žåãã³ã³ãããŒã©ãŒã¯ãªã³ã1ã®å Žåãã³ã³ãããŒã©ãŒã¯ã¹ãªãŒãã¢ãŒã ãããV-0ã®å ŽåãããŒã¿ãæžã蟌ãŸããåŸããã£ãªããžã¯Xã ã1ã·ããããã以å€ã®å Žåã¯Yã«ãã£ãŠ9ã·ããïŒèšé²ãããåã®çŽåŸïŒ ãããH-0ã®å Žåãéåžžã®åœä»€ã»ãããæäœããã¢ãŒãããªã³ã«ãªãã1ã®å Žå-æ¡åŒµ ãããDããã³Eã¯ã衚瀺ã¢ãŒããæ åœããŸãã 00-ãã¹ãŠã®ãã¯ã»ã«ããªãã§ã 01-ãã¹ãŠã®ãã¯ã»ã«ããªã³ 10-ã¡ã¢ãª1ã®ãã¯ã»ã«ã®ç¶æ ããªã³ã®å Žåããªã³ã®å Žåã0ã®å Žåããªãã§ãïŒéåžžã¢ãŒãïŒ 11-ã¡ã¢ãª1ã®ãã¯ã»ã«ã®ç¶æ ã®å Žåãç¹ç¯ããŸããã0ã®å Žåãç¹ç¯ããŸãïŒåè»¢ïŒ ãããTC1ããã³TC0ã¯ãLCD枩床ä¿æ°ãæ åœããŸã 00-ä¿æ°0 01-ä¿æ°1 10-ä¿æ°2 11-ä¿æ°3 ãããS1ãšS0ã¯ãå éšé»åä¹æ°ãã€ãŸã çè«çã«ã¯äœåé£ã¹ç©ã§ãã VDDã®ç³è«ã¯å éšé»æºãšã¯ç°ãªããŸã 00-2å 01-3åä»¥äž 10-4å 11-5å倧ãã Vop6-Vop0ãããã¯ãåæå éšé»å§ã®å€ãæ åœããŸã BS2-BS0ãããã¯ã·ã¹ãã ãã€ã¢ã¹ã®åå ã§ã
次ã«ãå¶åŸ¡çšã®å¯èœãªã³ãã³ããæäŸããŸãã ãããã¯ããããæ£ç¢ºã«8ãããã§æ§æãããŠããŸãã
ïŒæ瀺ã®ã©ã®ã¢ãŒãã§ãïŒ | ||||||||
ã¬ãžã¹ã¿PDãVãHãèšå®ããŸã | 0 | 0 | 1 | 0 | 0 | PD | V | H |
ïŒéåžžã¢ãŒãã§ã¯ãäžé£ã®æç€ºïŒ | ||||||||
ã¬ãžã¹ã¿DãEãèšå®ãã | 0 | 0 | 0 | 0 | 1 | D | 0 | E |
ãã£ãªããžã®X座æšãèšå®ããŸãïŒ ïŒ | 1 | X 6 | X 5 | X 4 | X 3 | X 2 | X 1 | X 0 |
ãã£ãªããžã®Y座æšãèšå®ããŸãïŒ ïŒ | 0 | 1 | 0 | 0 | Y 3 | Y 2 | Y 1 | Y 0 |
ïŒæ¡åŒµåœä»€ã»ããå ïŒ | ||||||||
TCã¬ãžã¹ã¿ãèšå®ãã | 0 | 0 | 0 | 0 | 0 | 1 | TC 1 | TC 0 |
ã¬ãžã¹ã¿Sãèšå®ãã | 0 | 0 | 0 | 0 | 1 | 0 | S 1 | S 0 |
BSã¬ãžã¹ã¿ãèšå®ãã | 0 | 0 | 0 | 1 | 0 | BS 2 | BS 1 | BS 0 |
ã¬ãžã¹ã¿Vã®èšå®ïŒ ïŒ | 1 V op 5 | V op 6 | V op 5 | V op 4 | V op 3 | V op 2 | V op 1 | V op 0 |
LCDãæ£ããåæåããã«ã¯ãVDDã«é»å§ãå°å ããRESããªãã«ããŠã100 µsåŸ ã£ãŠããRESã«å床å°å ããå¿ èŠããããŸãã RESã®é»æºããªãã«ãªããšãã³ã³ãããŒã©ãŒã¯ã¹ãªãŒãã¢ãŒãã«ãªããRAMã®ã¯ãªã¢ã¯ä¿èšŒãããŸãããå€ãã®ã¬ãžã¹ã¿ã¯ããã©ã«ãå€ãååŸããŸãã ã³ã³ãããŒã©ã®ããŒã¿ã·ãŒãã® 14ããŒãžãåç §ããŠãã ããã
ãã®åŸãSSããªãã«ãïŒã€ãŸããåäœããããã€ã¹ããéžæãïŒãDCããªãã«ãïŒã€ãŸããã³ãã³ãã®éä¿¡ãéå§ïŒãSPIã䜿çšããŠããã€ãã®åæåã³ãã³ããéä¿¡ããå¿ èŠããããŸãã
- é»æºãå ¥ããåæã«V = 0ãšH = 1ãèšå®ããŸã
- éžæ枩床ä¿æ°TC = 11
- æ倧å éšé»æºV op = 1111111ãèšå®ããŸã
- å éšåçS = 01ããªã³ã«ããŸã
- ã·ã¹ãã ãªãã»ãããèšå®ããŸãBS = 011
- éåžžã®åœä»€ã»ããã¢ãŒããæå¹ã«ããH = 0ãV = 0ãPD = 0
- éåžžã®è¡šç€ºã¢ãŒããéžæD = 1ãE = 0
ãã®åŸããã£ã¹ãã¬ã€ãç¹ç¯ããéãªã»ããRAMããååŸããã©ã³ãã ãªãã¯ã»ã«ã衚瀺ãããŸãã
æ®å¿µãªãããã³ã³ãããŒã©ãŒã«ã¯MOSIããªãïŒã€ãŸãããã£ãŒãããã¯ããªãïŒããããã£ã¹ãã¬ã€ã«äœã衚瀺ãããªãå Žåã¯ãå°ãªããšãSPIãæ©èœããããšã確èªããããã«ãäžèšã®ã³ãã³ãã®åŸãLCDã®7çªç®ã®ã¬ãã°ã®é»å§ã枬å®ããå¿ èŠããããŸãã
å®éšçãªïŒãããŠé·ãïŒæ¹æ³ã§ã次ã®ããšãå€æããŸããïŒãã£ã¹ãã¬ã€ã«äœã衚瀺ãããªããã7çªç®ã®ã¬ãã°ã«é»å§ãããå Žåãããã¯SPIãæ©èœããŠããããã£ã¹ãã¬ã€ã«ååãªå éšé»å§ããªããV opããã³Sã¬ãžã¹ã¿ïŒæ倧ã«èšå®ïŒã䜿çšããŠå¢å ããå¿ èŠãããããšãæå³ããŸãããšãã°ïŒã ç§ãã¡ã®å Žåããã£ã¹ãã¬ã€ã¯ã6Vã§ç¹ç¯ããŸãã
ç§ãã¡ã¯çè«ãç 究ããå®è£ ã«ç§»ããŸããã SPIã§ã®äœæ¥ãå®è£ ããã«ã¯ã2ã€ã®æ¹æ³ããããŸããããã»ããµã®ã¬ãã°ãå¶åŸ¡ããããšã§ãã¹ãŠã®ãã³ãã«ãå®è¡ããïŒãœãããŠã§ã¢spiïŒããŸãã¯STM32ã«ãããããŒããŠã§ã¢ãå®è£ ã䜿çšããïŒããŒããŠã§ã¢spiïŒã ããšãã°ãããã»ããµã®é»æºã䜿çšããŠã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããçç±ããªãã®ã§ãããŒããŠã§ã¢SPIã䜿çšããŸãã
CooCox IDEã§ã³ãŒããèšè¿°ããŠãããã°ããŸãã
- CoIDEãèµ·åããŠãæ°ãããããžã§ã¯ããäœæããŸãã
- å¿
èŠãªã¢ãžã¥ãŒã«ãéžæããŸãïŒGPIOïŒã¬ãã°ã®å¶åŸ¡çšïŒãSPIïŒSPIã®å¶åŸ¡çšïŒãRCC
- å°æ¥ã®ããã°ã©ã ã®ããã«å°ããªãã¬ãŒã ã¯ãŒã¯ãäœæããŸã
#include "stm32f10x_gpio.h" #include "stm32f10x_rcc.h" #include "stm32f10x_spi.h" void SPIInit(void) { } void GPIOInit(void) { } void LCDInit(void) { } int main() { SystemInit(); GPIOInit(); SPIInit(); LCDInit(); return 0; }
- GPIOã«å
¥åããããšããå§ããŸãããã ãããè¡ãã«ã¯ãSTM32ã®ããŒã¿ã·ãŒãã䜿çšããŠããéãSPIã®è¶³ãã©ãã«ãããã調ã¹ãå¿
èŠããããŸãã ã¢ãã«ã¯PA5ïŒSCKïŒãPA6ïŒMISOïŒãPA7ïŒMOSIïŒã§ãã ãããã®ã¬ãã°ã¯éåžžã®ã¬ãã°ãŸãã¯SPIã¬ãã°ã®ããããã§ãããããæå³ããç®çãæ確ã«ç€ºããŠäœ¿çšããå¿
èŠããããŸãã
- æ®ãã®èãèæ
®ããŠãã ããïŒ
Vdd é»æºãæ¥ç¶ããããã®è¶³ãSTM32ã®ä»»æã®èã«æ¥ç¶ããŸãïŒãã®å ŽåãLPH7999-4ã§ã¯ãæ¥ç¶å¶éã¯æ倧6.5Vã§ãSTM32ã¯åèã«3.3VãäŸçµŠããŸãïŒ Vout x mFã®ã³ã³ãã³ãµãä»ããŠç»é¢ã®ã°ã©ã³ãã«æ¥ç¶ãããå éšé»æºåºåã GND ã°ã©ãŠã³ããVOUTãåç § RES ã³ã³ãããŒã©ãŒã®ãªã»ãããå¶åŸ¡ããããã®ããããSTM32ã®ä»»æã®ãããã«æ¥ç¶ DC ã³ã³ãããŒã©ãžã®ããŒã¿è»¢éã¢ãŒããæ åœããã¬ãã°ã¯ãSTM32äžã®ä»»æã®ã¬ãã°ã«æ¥ç¶ãããŸãã èã«é»å§ããªãå ŽåãLCDã³ã³ãããŒã©ãŒã¯åä¿¡ããããŒã¿ãã³ãã³ããšããŠè§£éããããå Žåããã£ãªããžã®äœçœ®ã«å¯ŸããŠDDRAMã®åã«æžã蟌ãŸãã8ãã¯ã»ã«ã®ã»ãããšããŠè§£éããŸãã SS äžèšãåç §ãSTM32ã®ä»»æã®ã¬ãã°ã«æ¥ç¶
- SCKãMOSIãPA5ããã³PA7ã«ã¯ãã ä»ãããDCãVDDãRESããã³SSãä»»æã®èã«ã¯ãã ä»ãããŸãã ããããPB0ãPB1ãPB2ãPB3ããããŸãã
- ã³ãŒããæžããŸãïŒ
#define SCK_Pin GPIO_Pin_5 #define SCK_Pin_Port GPIOA #define MOSI_Pin GPIO_Pin_7 #define MOSI_Pin_Port GPIOA #define DC_Pin GPIO_Pin_0 #define DC_Pin_Port GPIOB #define VDD_Pin GPIO_Pin_1 #define VDD_Pin_Port GPIOB #define RST_Pin GPIO_Pin_2 #define RST_Pin_Port GPIOB #define SS_Pin GPIO_Pin_3 #define SS_Pin_Port GPIOB void GPIOInit(void) { // (=) A, B SPI1 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_SPI1, ENABLE); GPIO_InitTypeDef PORT; // PORT.GPIO_Pin = SCK_Pin | MOSI_Pin; // ( 4 ) PORT.GPIO_Speed = GPIO_Speed_2MHz; // (!) . - " " PORT.GPIO_Mode = GPIO_Mode_AF_PP; // GPIO_Init(GPIOA, &PORT); // PORT.GPIO_Pin = DC_Pin | VDD_Pin | RST_Pin | SS_Pin; // ( - ) PORT.GPIO_Speed = GPIO_Speed_2MHz; // - , PORT.GPIO_Mode = GPIO_Mode_Out_PP; // B GPIO_Init(GPIOB, &PORT); }
ã³ãŒããèªã¿ãããããããã®è£å©ããã·ãŒãžã£ãäœæããŸãã
void PowerOn() { VDD_Pin_Port->ODR |= VDD_Pin; } void PowerOff() { VDD_Pin_Port->ODR &= ~VDD_Pin; } void ResetOn() { RST_Pin_Port->ODR |= RST_Pin; } void ResetOff() { RST_Pin_Port->ODR &= ~RST_Pin; } void DCOn() { DC_Pin_Port->ODR |= DC_Pin; } void DCOff() { DC_Pin_Port->ODR &= ~DC_Pin; } void SSOff() { SS_Pin_Port->ODR &= ~SS_Pin; } void SSOn() { SS_Pin_Port->ODR |= SS_Pin; }
- 次ã«SPIãæ§æããŸãã
void SPIInit(void) { SPI_InitTypeDef SPIConf; // , SPIConf.SPI_Direction = SPI_Direction_1Line_Tx; // , - Master SPIConf.SPI_Mode = SPI_Mode_Master; // 8 (=1 ) SPIConf.SPI_DataSize = SPI_DataSize_8b; // 00 SPIConf.SPI_CPOL = SPI_CPOL_Low; SPIConf.SPI_CPHA = SPI_CPHA_1Edge; SPIConf.SPI_NSS = SPI_NSS_Soft; // ( , ) SPIConf.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; // (.. ) SPIConf.SPI_FirstBit = SPI_FirstBit_MSB; // SPI SPI_Init(SPI1, &SPIConf); // SPI1 SPI_Cmd(SPI1, ENABLE); // SS = 1 SPI_NSSInternalSoftwareConfig(SPI1, SPI_NSSInternalSoft_Set); }
- SPIã§ããŒã¿ãéä¿¡ããæ©èœãæžããŸããã
void SPISend(uint16_t data) { SPI_I2S_SendData(SPI1, data); // while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); // , }
- çè«ã«åŸã£ãŠåæåãæžããŸããã
void LCDInit(void) { SSOff(); DCOff(); PowerOn(); ResetOff(); ResetOn(); SPISend(0x21); // , , . . SPISend(0b1001); // SPISend(0xFF); // SPISend(0x06); // SPISend(0x13); // bias ( ) SPISend(0x20); // ..., SPISend(0b1100); // }
- ãããžã§ã¯ã-ãã«ãïŒãŸãã¯F7ïŒ
- ãã©ãã·ã¥-ããã°ã©ã ã®ããŠã³ããŒã
- ç§ãã¡ã¯èŠãŠåãã§ããŸãïŒ3
ããã§ã¯ãCooCoxã®å®æãããããžã§ã¯ããããŠã³ããŒãã§ããŸãã
ãã¡ããã2013幎ã«ã¯ãARMããã»ããµã§æ¥ç¶ããããã£ã¹ãã¬ã€ãé©ããããšã¯å°é£ã§ãã ç§ãã¡ã«ãšã£ãŠãåå¿è ã®éçºè ã«ãšã£ãŠãããã¯ç§ãã¡ã®ãŠããŒã¯ãªãé»åãã¬ã¹ã¬ããããããžã§ã¯ãã®å®è£ ã«åããæåã®ã¹ãããã§ãã
åžå Žãžã®åå ¥ã倢èŠãŠããã®ã§ã¯ãªããçµéšãç©ã¿ãæ©èœçã§ã¹ã¿ã€ãªãã·ã¥ã§é·æã¡ããã¬ãžã§ãããèªåã§äœããåæã«ããã§æåãšå€±æãäŒãããã ãã§ãã
ããã§ãããã€ã¹ã¯ç»é¢äžã«ç»åãæç»ã§ããããã«ãªããŸããã以åã¯ãPython 2.7ãšPILãå¿ èŠãšãããã® Python ã¹ã¯ãªããã䜿çšããŠã8ãããã®ãåãã®é åã«å€æãããŠããŸããã
䜿çšæ³ïŒ photo.py file24bit.bmp> bytes.c
ããã€ãã®å³ã¯http://easystm32.ru/interfaces/43-spi-interface-part-1ããåãããŸãã