SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
ī„ ī„ 

     ī„  ī„ ī†Šī…šī…°ī…Ĩī…Ŋī…ģī…ī„ ī…Œī…‚ī…Ŋī…šī…’ī…‹ī…Ŋī…ģī…ī„ ī†Ēī…ī…Ŋī…šī…‰

                     â€ĢīēīģŸīē˜īē īēŽīē­īē īēīģŸīģŒīģ¤īģ īģ´īē”â€Ŧ

                  ī„  ī„ ī†Ēī…ī…ģī…‚ī…ī…ģī…ī„ ī†Ēī…Ąī…ģī…ī…ģī…

                          ī„ ī„ 




                          ī„ ī„ 




                   Programming
      Embedded Systems Microcontroller

You Can Practice Microcontroller Programming Easily Now!
      WALID BALID, Tuesday, December 15, 2009
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                             īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

      Exp.5: Hexadecimal Array Keypad                   īˆ  īˆ ī‹’ī‹ŽīŠ¯ī‹ŒīŠ°ī‰ļīŠŋīˆ ī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ īˆēī‹’ī‰ŽīŠŋī‰‚īŠˆī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰


                                                                                             īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰
                                                                    īˆ  īˆ īˆŽī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰
                                                                                               īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹




īˆ  īˆ 
                                                                                               īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą
  īˆ ī‹‘ī‰¨īŠ¯ī‰‚ī‹„īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹ī‰­ī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋī‹‹īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹’īŠ¯ī‰ĒīŠ¨īŠŋī‹‹īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠ´īŠģīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­
                                                                                                     īˆ  īˆ īˆŽī‹’ī‹ŽīŠŧī‰ŽīŠŧī‰Žī‰ŽīŠģī‰
                                                                                            īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰
                                      īˆ  īˆ īˆēīŠ”ī‰Žī‹Žī‰­ī‰‚ī‰­ī‰ƒīˆ īŠ”ī‰Žī‹Žī‹€ī‹ŽīŠŧīŠ¨ī‰īˆ īŠ•ī‰‡īˆ ī‰˜ī‰‚ī‰ŽīŠīˆ ī‰‚ī‹„ī‹ƒī‰ˆīŠ¯īˆ ī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗīˆ īŠŊī‰•ī‰ƒīˆ ī‹…īŠŋ
                      īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰                                   īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą
                                                         īˆ īˆ—ī‰Ąī‰„ī‰ŽīŠģī‰īˆ ī‹…īŠŋī‰Ģīˆ īŠąī‹ī‰ĒīŠ¨ī‰ī‹‹īˆ  ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ īŠžī‹Œī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
       īˆ  īˆ Config     Kbd = Portb , Delay = 150
                                                                         īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°ī‹€īŠŧīŠģīˆ ī‹’ī‹ŽīŠ¸ī‹Žī‹ƒī‰‚īŠ¸ī‹ŽīŠī‰īˆ ī‹’īŠģī‰‚ī‹ąīŠ¨īŠģī‰īˆ ī‰Ēī‰‘ī‰ƒīˆ ī‹ī‰Ĩī‰‚īŠ°ī‰ŽīŠģ
                                                                                      īˆ  īˆ īˆēī‹‰ī‹ƒī‰ƒīˆ ī‰“ī‹Žī‰™īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗ
                                                         īˆ ī‹…īŠ¸ī‹īˆ  īˆ…īˆ  ī‰ī‰§ī‰‡īˆ  Var = 16īˆ  ī‹’ī‹€ī‹ŽīŠ´īŠģī‰‚ī‰‰īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ  ī‹Šī‰¨ī‹‡īˆ  ī‰Ĩī‹ŒīŠ¨ī‰Žī‰­ īˆ  īˆ­1
                    īˆ  īˆ Var    = Getkbd()                                               īˆŽīŠĸī‹ŒīŠŦī‰ēīŠŋīˆ ī‰ ī‰‚ī‰ŽīŠ°īŠŋīˆ ī‹ī‰ƒīˆ īŠēī‰‚ī‹„ī‹‡
                                                         īˆ īŠŊīŠ¸ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ  īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹’ī‹€ī‹ŽīŠ´ī‰‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹Šī‰¨ī‹‡īˆ ī‰Ĩī‹ŒīŠ¨ī‰Žī‰­ īˆ  īˆ­ 2
                                                                                                      īˆ  īˆ  īˆēī‹īŠģī‰‚ī‰ŽīŠģī‰

      ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ                      58                          ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                      Programming Microcontrollers

                                                                    S1 = 0
                                                                    S2 = 1
                                                                    S3 = 2
                                                                    S4 = 4
                                                                    S5 = 5
                                                                    S6 = 6
                                                                    S7 = 8
                                                                    S8 = 9
                                                                   S9 = 10
                                                                   S* = 12
                                                                   S0 = 13
                                                                   S# = 14
                                                                    A=3
                                                                    B=7
                                                                    C = 11
                                                                   D = 15
                                                                           īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰
$regfile = "m128def.dat"
$crystal = 1000000                                                  īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰
$baud = 4800
'-----------------------
Config Kbd = Portb , Delay = 150                     īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
'-----------------------
Dim Var As Byte                                                  īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
'-----------------------
Do
   Var = Getkbd()
      If Var < 16 Then
         Gosub Check_number                      īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗīˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™
      End If
                                                                         īˆ  īˆ 
Loop

End
'-----------------------
Check_number:
Select Case Var
   Case 0 : Print "Key Pressed is (1)"
   Case 1 : Print "Key Pressed is (2)"
   Case 2 : Print "Key Pressed is (3)"
   Case 3 : Print "Key Pressed is (A)"
   Case 4 : Print "Key Pressed is (4)"
   Case 5 : Print "Key Pressed is (5)"
   Case 6 : Print "Key Pressed is (6)"
   Case 7 : Print "Key Pressed is (B)"             īˆ ī‹ī‰‘īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰‚ī‰‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋīˆ ī‹īŠ§ī‰ĒīŠ°īŠģīˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰
   Case 8 : Print "Key Pressed is (7)"
   Case 9 : Print "Key Pressed is (8)"                     īˆ  īˆ īˆŽī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ īŠ•ī‰‡īˆ ī‹‘ī‰Ĩī‹ŒīŠ¨īŠģī‰
   Case 10 : Print "Key Pressed is (9)"
   Case 11 : Print "Key Pressed is (C)"
   Case 12 : Print "Key Pressed is (*)"
   Case 13 : Print "Key Pressed is (0)"
   Case 14 : Print "Key Pressed is (#)"
   Case 15 : Print "Key Pressed is (D)"
End Select
Return
'-----------------------

Faculty of Electrical and Electronic Eng.   59                 Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                              īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

      Exp.6: Programming LCD                                  īˆ  īˆ ī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰īˆ īˆēī‹’ī‰­ī‰Ĩī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰


                                                                                              īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰
                                                                      īˆ  īˆ īˆŽ20x4īˆ ī‹’ī‹ŽīŠ¯ī‰ĒīŠŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰
                                                                                                 īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹




īˆ  īˆ 
                                                                                                 īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ
                                                                                      īˆ  īˆ īˆŽSW2īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ
                                                                                                 īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą
  īˆ ī‰žī‰ī‰ĒīŠ¨ī‰Žī‰­ī‰īˆ  īŠ•ī‰‡īˆ  ī‹’īŠ¯ī‰‚ī‰šī‹ĸī‰‚ī‰‰īˆ  ī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠˇīˆ  ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ  ī‹’ī‰ąī‰‚ī‰ąīˆ  ī‹“īŠŧīŠ§īˆ  ī‹’ī‹Žī‰ļī‹ƒīˆ  īŠ˛ī‰Šī‰‚īŠŠīˆ  ī‰Šī‰‚ī‹ˆīŠŖī‹ĸīˆ  ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ  ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ  ī‹‚ī‹ŒīŠ´ī‹ƒīˆ  īŠ˛ī‹Œī‰­
                                                                      īˆ  īˆ īˆŽī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰‚ī‰‰īˆ ī‹’ī‰ĩī‰‚īŠˆī‰īˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰
                                                                                             īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰
                      īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰                                     īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą
      Config Lcdpin = Pin ,
      Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6                     īˆ  īˆ īˆ’ī‰‚īŠ¨īŠī‰īˆ īŠŠīŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Œī‰‚ī‹ąīŠŗī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰
      Db7 = Portc.7 ,ī„ ī„ ī„ ī„ ī„ E = Portc.2 , Rs = Portc.3
      Config Lcd = 20 * 4                                                īˆ  īˆ īˆ¨ī‰Ēī‹ąī‰­ī‰ƒīˆ īˆĒīˆ ī‹‘ī‰Ļī‹€īŠ§ī‰ƒīˆŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Ĩī‰‚īŠ¨ī‰‰ī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰
      Deflcdchar 0 , 14 , 17 , 14 , 17 , 17 , 14 , 17 , 14            LCD Designerīˆ ī‹‘ī‰ī‰Ĩī‹žī‰īˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ īŠŸī‰‚ī‰šī‰‡īˆ īŠ˛ī‰ĒīŠŠīˆ īŠąī‹ī‰ĒīŠ¨ī‰

      Cls                                                                                        īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰œī‰ŽīŠŋ

      ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ                           60                      ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                      Programming Microcontrollers

Lcd var                                                       īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹“īŠŧīŠ§īˆ īŠ˛ī‰ĒīŠŠ/ī‹’ī‹€ī‹ŽīŠŗīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
Lowerline                                                     īˆ  īˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠšī‹ī‰ĒīŠ„
Shiftlcd Right                              īˆ  īˆ īˆ īŠ”ī‹€ī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‹‘ī‰Ēī‹ˆīŠ¤īŠī‰īˆ ī‰ī‰‚īŠŋī‹ŒīŠŧīŠ¨īŠī‰īˆ īŠŠī‹ŽīŠšīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡
Shiftlcd Left                               īˆ  īˆ īˆ ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‹‘ī‰Ēī‹ˆīŠ¤īŠī‰īˆ ī‰ī‰‚īŠŋī‹ŒīŠŧīŠ¨īŠī‰īˆ īŠŠī‹ŽīŠšīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡
Locate X , Y                                              īˆ  īˆ īˆ¨ī‰Ĩī‹Œī‹€īŠ§/ī‰Ēī‹ąī‰­īˆŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹Œī‰
Shiftcursor Right                                        īˆ  īˆ īŠ”ī‹€ī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ļī‰™ī‰ī‹‹īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡
Shiftcursor Left                                         īˆ  īˆ ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ļī‰™ī‰ī‹‹īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡
Home Upper                                             īˆ  īˆ īˆ¨ī‹’ī‹ī‰ī‰Ļī‰ŠīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆŠīˆ īŠžī‹‹ī‹žī‰īˆ ī‰Ĩī‹Œī‹€īŠ¨īŠģī‰/ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰
Cursor Off Noblink                                                             īˆ  īˆ īˆŽī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹•ī‰‚īŠŦīŠģī‰‡
Cursor On Blink                                                      īˆ  īˆ ī‹†ī‰‚īŠ´īŠ°ī‰Ąīˆ īŠŠīŠŋīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŊī‹ŽīŠŦī‰˛ī‰
Display Off                                                                     īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹•ī‰‚īŠ°ī‰ŋī‰‡
Display On                                                                     īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŊī‹ŽīŠŦī‰˛ī‰
Thirdline                                                                 īˆ  īˆ ī‰“īŠģī‰‚ī‰’īŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰
Fourthline                                                                 īˆ  īˆ īŠŠī‰‰ī‰ī‰ĒīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰
Home Third                                                 īˆ  īˆ ī‰“īŠģī‰‚ī‰’īŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹‹
Home Fourth                                                īˆ  īˆ īŠŠī‰‰ī‰ī‰ĒīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹‹
Lcd Chr(x)                                                                   īˆ  īˆ īŠŸī‰‚ī‰šī‹ĸī‰īˆ īŠ˛ī‰Ēīˆī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ


                                                                            īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰
$regfile = "m128def.dat"                                                    īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰
$crystal = 8000000
'-----------------------                                          īˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Œī‰‚ī‹ąīŠŗī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 ,
Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.3                 īˆ  īˆ īˆŽī‹īŠ¸ī‰šī‰ŽīŠī‰īˆ īŠŠīŠŋ
                                                                    īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠ¤īŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŊī‹ī‰Ĩī‹ŒīŠŋīˆ īŠąī‹ī‰ĒīŠ¨ī‰
Config Lcd = 20 * 4
                                                                    īˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‹’ī‹ŽīŠ¯ī‰‚ī‰šī‰‡īˆ īŠ˛ī‰Šī‰‚īŠŠīˆ īŠąī‹ī‰ĒīŠ¨ī‰
Deflcdchar 0 , 14 , 17 , 14 , 17 , 17 , 14 , 17 , 14
Deflcdchar 1 , 17 , 14 , 17 , 14 , 14 , 17 , 14 , 17                       LCD Designerīˆ ī‹‘ī‰ī‰Ĩī‹žī‰
'-----------------------
                                                                         īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
Dim A As Byte
'-----------------------
Do
   Cls
   Lcd "hello world!"
   Wait 1                                                             īˆ  īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™
                                                                   īˆ  īˆ īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ 
    Lowerline
    Wait 1                                                         īˆ  īˆ īˆ ī‹’ī‹Žī‰­ī‰‚ī‰­ī‹žīˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰īˆ ī‰žī‰ĒīŠ§ī‹‹
                                                                     īˆ  īˆ īˆŽī‹’ī‹ŽīŠ¯ī‰‚ī‰šī‹ĸī‰īˆ īŠ˛ī‰Šī‰‚īˆī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡ī‹‹
    Lcd "LCD Test"
    Wait 1

    For A = 1 To 8
       Shiftlcd Right

Faculty of Electrical and Electronic Eng.   61                  Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                    īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

       Waitms 500
    Next A

    For A = 1 To 8
       Shiftlcd Left
       Waitms 500
    Next A

    Locate 2 , 9
    Lcd "-L2,C9"
    Wait 1

    Shiftcursor Right
    Lcd "-*-"
    Wait 1

    Shiftcursor Left
    Lcd "*-*"
    Wait 1

    Home Upper
    Lcd "HELLO WORLD"
    Wait 1

    Cursor Off Noblink
    Wait 1

    Cursor On Blink
    Wait 1

    Display Off
    Wait 1

    Display On
    Wait 1

    Thirdline
    Lcd "   /Line 3"
    Wait 1

    Fourthline
    Lcd "   /Line 4"
    Wait 1

    Home Third
    Lcd ":)"
    Wait 1

    Home Fourth
    Lcd ":("
    Wait 1

   Cls
   Locate 1 , 9 : Lcd Chr(0)
   Wait 1
   Locate 1 , 11 : Lcd Chr(1)
Loop

End
ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ    62   ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                      Programming Microcontrollers

      Exp.7: Programming Graphic LCD                   īˆ  īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰īˆ īˆēī‹’īŠ¨ī‰‰ī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰


                                                                                     īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰
                                                          īˆ  īˆ īˆŽ128x64īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰
                                                                                       īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹




īˆ  īˆ 
                                                                                       īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ
                                                                             īˆ  īˆ īˆŽSW3īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ
                                                                                       īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą
  īˆ īŠ•ī‰‡īˆ ī‹’īŠ¯ī‰‚ī‰šī‹ĸī‰‚ī‰‰īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹“īŠŧīŠ§īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰ī‰ī‹•ī‰‚ī‰˛ī‹ƒī‰‡ī‹‹īˆ ī‰Šī‹Œī‰ĩī‹‹īˆ ī‹’ī‹Žī‰ļī‹ƒīˆ īŠ˛ī‰Šī‰‚īŠŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­
                                                   īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰‚ī‰‰īˆ ī‹’ī‰ĩī‰‚īŠˆī‰īˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰īˆ ī‰žī‰ī‰ĒīŠ¨ī‰Žī‰­ī‰
                                                                                   īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰
                          īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰                       īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą
   Config Graphlcd = 128 * 64sed ,
   Dataport= Porta, Controlport= Portc ,
   Ce = 2 , Ce2 = 4 , Cd = 7 , Rd = 6 ,
                                                          īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŠīŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Œī‰‚ī‹ąīŠŗī‹žī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
īˆ  īˆ Reset = 3 , Enable = 5
īˆ  īˆ $lib       "glcdKS108.lib"                                        īˆ  īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’ī‰Šī‰ŽīŠ¸īŠŋīˆ īŠąī‹ī‰ĒīŠ¨ī‰
      Faculty of Electrical and Electronic Eng.   63                   Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                       īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

Setfont Font                                                               īˆ  īˆ ī‹‰īŠŋī‰ī‰Ļī‰ĸī‰Žī‰­ī‰īˆ ī‰Ĩī‰ī‰ĒīŠī‰īˆ īŠĄīŠˆī‰īˆ īŠ”ī‹ŽīŠ¨ī‰
Cls                                                                            īˆ  īˆ ī‹‚ī‹Œī‰­ī‰ĒīŠģī‰ī‹‹īˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰œī‰ŽīŠŋ
Cls Text                                                                          īˆ  īˆ īŠĄīŠ´īŠ¯īˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰œī‰ŽīŠŋ
Cls Graph                                                                           īˆ  īˆ īŠĄīŠ´īŠ¯īˆ ī‹‚ī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰œī‰ŽīŠŋ
Lcdat y , x , var [, inv]                              īˆ  īˆ īˆŽī‰Ĩī‰ĻīŠŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ˇī‹ƒīˆ ī‹‹ī‰ƒīˆ īŠžī‹Œī‰šī‰ŽīŠŋīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
Line(X0 , Y0) - (X1 , Y1) , Color                           īˆ  īˆ ī‹’ī‹ī‰‚ī‹ˆī‹ƒīˆ ī‹’ī‹ąīŠ´ī‹ƒī‹‹īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‰‚ī‹„ī‰Žī‰­ī‰īˆ īŠĄī‰Ąīˆ ī‹ī‰­ī‰Š
Pset X , Y , Color                                    īˆ  īˆ īˆ¨SET/RST PixelīˆŠīˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ ī‹•ī‰‚īŠ°ī‰Ąī‰‡īˆ ī‹‹ī‰ƒīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰ˆī‰‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰
Circle(X , Y) , r , Color                                             rīˆ ī‰Ēī‹ąīŠ´ī‰‰ī‹‹īˆ ī‹’ī‹ŽīŠ¨ī‰•ī‰ĒīŠŋīˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŸīˆ ī‹‘ī‰Ēī‹–ī‰ī‰Ĩīˆ ī‹ī‰­ī‰Š
Showpic X , Y , label                               īˆ  īˆ ī‹‘ī‰Ĩī‰ĻīŠŠīˆ ī‹’ī‰ŽīŠ¯ī‹œīˆ ī‰Ļī‹„īŠ§īˆ ī‹‘ī‰Ĩī‹Œī‰•ī‹ŒīŠŋīˆ ī‰Ĩī‰ĻīŠŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹‘ī‰Šī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡
$include "Font5x8.font"                                   īˆ  īˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ īŠĸī‹Œī‹ąī‰Ąīˆ īŠąīŠŧīŠŋīˆ ī‹…īŠŋīˆ īŠĸī‹Œī‹ąīŠˆī‰īˆ īŠąīŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰
$bgf "Smiley1.bgf"                                                 īˆ  īˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ bgfīˆ īŠąīŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠ”ī‹€ī‰ēī‰
                                                                              īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰
$regfile = "m128def.dat"
$crystal = 8000000                                                īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰
$lib "glcdKS108.lib"
'-------------------------
Config Graphlcd = 128 * 64sed , Dataport
= Porta , Controlport = Portc , Ce = 2 ,
Ce2 = 4 , Cd = 7 , Rd = 6 , Reset = 3 ,         īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
Enable = 5
'-------------------------
Dim X As Byte , Y As Byte                                      īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
'-------------------------
Cls : Cls Text : Cls Graph                                    īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰œī‰ŽīŠŋ
'-------------------------
Setfont Font8x8
   Lcdat 3 , 11 , "Font 5x8 Test"
   Lcdat 4 , 11 , "Font 6x8 Test"                    8x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
   Lcdat 5 , 11 , "Font 8x8 Test"
   Wait 2

    Cls
    Setfont Font5x8                               īˆ  īˆ 5x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
        Lcdat 1 , 1 , "LINE1" : Wait 1
        Lcdat 2 , 1 , "LINE2" : Wait 1
        Lcdat 3 , 1 , "LINE3" : Wait 1

    Setfont Font6x8
       Lcdat 4 , 1 , "LINE4" : Wait 1             īˆ  īˆ 6x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
       Lcdat 5 , 1 , "LINE5" : Wait 1
       Lcdat 6 , 1 , "LINE6" : Wait 1

   Setfont Font8x8
      Lcdat 7 , 1 , "LINE7" : Wait 1              īˆ  īˆ 8x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ
      Lcdat 8 , 1 , "LINE8" : Wait 1
'/------------/
Cls
Setfont Font16x16                               īˆ  īˆ 16x16īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ



ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ               64                           ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                            Programming Microcontrollers

   Lcdat 4 , 23 , "16x16" : Wait 2
   Cls
       Lcdat 1 , 1 , "LINE1" : Wait 1
       Lcdat 3 , 1 , "LINE2" : Wait 1
       Lcdat 5 , 1 , "LINE3" : Wait 1
       Lcdat 7 , 1 , "LINE4" : Wait 1
'/------------/
Setfont Font8x8
   Lcdat 4 , 11 , "Drawing Lines" :
Wait 2
   Cls Text                                            ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģīˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰īˆ ī‹ī‹Žī‰ŽīŠ´ī‰ŽīŠģī‰īˆ īŠĩīŠ¯ī‹‹īˆ īŠĸī‹Œī‹ąī‰Ąīˆ ī‹ī‰­ī‰Š
       Line(0 , 0) -(127 , 0) , 255                        Y
                                                                                 63,31
       Wait 1                                                                                   127,0
       Line(0 , 63) -(127 , 63) , 255            0,0

       Wait 1
       Line(0 , 0) -(0 , 63) , 255
       Wait 1
       Line(127 , 0) -(127 , 63) , 255
       Wait 1                                                                                    127,63
                                            0,63
       Line(0 , 0) -(127 , 63) , 255
                                      īˆ  īˆ 
                                                                                                X
       Wait 1
       Cls Graph                                                          īˆ  īˆ 
'/------------/
   Lcdat 4 , 11 , "SET/RST Pixel" :
Wait 2
   Cls Text
       For X = 0 To 127
          Pset X , 20 , 255
          Pset X , 43 , 255
          Waitms 200
       Next X

         For Y = 0 To 63
            Pset 42 , Y , 255
            Pset 86 , Y , 255
            Waitms 200
         Next Y

         For X = 127 To 0 Step -1
            Pset X , 20 , 0
            Pset X , 43 , 0
            Waitms 200
         Next X                                                īˆ  īˆ īˆ ī‹’ī‹ąīŠ´ī‹„ī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠĸī‹Œī‹ąī‰Ąīˆ ī‹ī‰­ī‰Š
                                                               īˆ  īˆ ī‹’ī‹ąīŠ´ī‹„ī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ ī‰‚ī‹ˆī‰šī‰ŽīŠŋīˆ ī‹ī‰‘īˆ ī‹…īŠŋī‹‹
       For Y = 63 To 0 Step -1
          Pset 42 , Y , 0
          Pset 86 , Y , 0
          Waitms 200
       Next X
       Cls Graph
'/------------/
   Lcdat 4 , 11 , "Drawing Circle" :
Wait 2
   Cls Graph
   For X = 1 To 31                                                       ī‹‘ī‰Ēī‹–ī‰ī‰Ĩīˆ ī‹ī‰­ī‰Š
       Circle(63 , 31) , X , 255
       Waitms 200
       Circle(63 , 31) , X , 0
   Next X                                                                 īˆ  īˆ 

Faculty of Electrical and Electronic Eng.   65                        Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                      īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

   Cls Graph
                                                                      īˆ  īˆ 
'/------------/
   Showpic 0 , 0 , Smiley1
   Wait 2
   Cls : Cls Text : Cls Graph

    Showpic 0 , 0 , Smiley2
    Wait 2
    Cls Graph
                                                     īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹’ī‹„ī‹€ī‰ēīŠī‰īˆ ī‰Šī‹Œī‰ļīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡
    Showpic 0 , 0 , Smiley3
    Wait 2
    Cls Graph

   Showpic 0 , 0 , Smiley4
   Wait 2
'/------------/
  Glcdcmd &H3E , 1 : Glcdcmd &H3E , 2 īˆ  īˆ ī‹ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰ī‹‹īˆ īˆŸī‹Žī‹€ī‹ŽīŠģī‰īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹ī‹€ī‰ŽīŠŗīˆ ī‹•ī‰‚īŠ°ī‰ŋī‰‡īˆ  īˆ­
  Wait 1
  Glcdcmd &H3F , 1 : Glcdcmd &H3F , 2               īˆ  īˆ īŠ”ī‹€ī‰ŽīŠ´īŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‹‘ī‰Ĩī‰‚īŠ§ī‰‡īˆ īˆ  īˆ­
'/------------/
End
'-------------------
$include "Font5x8.font"
$include "Font6x8.font"                īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹’ī‹ŽīŠ‰ī‰Ēī‰‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰
$include "Font8x8.font"
$include "Font16x16.font"
'-------------------
Smiley1:
$bgf "Smiley1.bgf"

Smiley2:
$bgf "Smiley2.bgf"
                                                  īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‰Šī‹Œī‰ļīŠģī‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰
Smiley3:
$bgf "Smiley3.bgf"

Smiley4:
$bgf "Smiley4.bgf"
                                                                                                     īˆ  īˆ īˆ 




ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ                 66                        ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                          Programming Microcontrollers

Exp.8: Generating Tones                                          īˆ  īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īˆēī‹’ī‹„īŠŋī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰


                                                                                   īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰
                                                          īˆ  īˆ īˆŽī‹ī‰ī‹Œī‰ļīŠģī‰īˆ ī‹‰ī‹Žī‰Šī‹„ī‰ŽīŠģī‰īˆ ī‰žī‰ī‰ĒīŠĢī‹žīˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰
                                                                                   īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹




                    īˆ  īˆ 
                                                                                    īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ
                                            īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŠī‰šī‹‹ī‹‹īˆ .Jumperīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰ JP16īˆ īŠŊī‰ĩī‹ŒīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ
                                                                 īˆ  īˆ īˆŽī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠŸīˆ ī‰‚ī‹€īŠˇīˆ PB4,PB5īˆ īŠ”ī‰‰īˆ īŠŊī‰ĩī‹‹
                                                                                   īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą
                                            īˆ ī‹“īŠŧīŠ§īˆ ī‰Ēī‹ˆīŠ¤ī‰īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‹‰ī‹Žī‰Šī‹„ī‰īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰ŽīŠģīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­
                                            īˆ ī‰—īŠŋī‰Ĩīˆ īŠžī‹ī‰Ąīˆ ī‹…īŠŋīˆ ī‹’ī‹€īŠŦī‹ƒīˆ ī‹ī‰ƒīˆ īŠŊī‹ŽīŠ¸ī‰˛ī‰īˆ ī‹…īŠ¸īŠ™īˆ īˆŽī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹ī‰ī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠ‰
                                            īˆ ī‰žī‰ĒīŠ§īˆ īˆ—ī‹ŽīŠŦī‰ī‹‹īˆ ī‹’ī‰ēī‰Šī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ īˆžīŠģī‰īˆ  soundīˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰īˆ ī‹‘ī‰ĻīŠ§
īˆ  īˆ īˆ¨SpeakerīˆŠīˆ ī‹ī‰•ī‰Šī‰‚īŠˆī‰īˆ ī‰Šī‰‚ī‹ˆīˆ‘ī‰‚ī‰‰īˆ ī‹īŠ¸ī‰šī‰Žī‹īˆ ī‹ī‰¨īŠģī‰īˆ ī‹ī‰Šī‹Œī‰Žī‰­ī‰Ŧī‹ƒī‰īˆ–īŠģī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹‘ī‰ĻīŠ§ī‰‚īŠŗīˆ ī‹“īŠŧīŠ§īˆ ī‰Ĩī‰Ĩīˆ–īŠģī‰īˆ īˆ—īŠŦī‰Žī‹īˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰‚ī‰‰ī‹‹īˆ ī‹’ī‰ēī‰Šī‹„īŠģī‰īˆ ī‰Šī‹‹ī‰Ĩī‹‹


Faculty of Electrical and Electronic Eng.           67               Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                 īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

                                                                              īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰
                  īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰                       īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą
                                           īˆ ī‰Ĩī‰ĻīŠŠīˆ  ī‹’ī‰ēī‰Šī‹ƒīˆ  ī‰žī‰ĒīŠ¨ī‰‰ī‹‹īˆ  īˆ¨SpeakerīˆŠīˆ  ī‰‹ī‹ąīŠ´īŠģī‰īˆ  ī‹“īŠŧīŠ§īˆ  ī‰ī‹Œī‰ĩīˆ  ī‰Ļī‹ŽīŠģī‹Œī‰
īˆ  īˆ Sound   Speaker , Pulses , Periods
                                         īˆ  īˆ īˆŽīˆ¨PeriodsīˆŠīˆ īŠžī‹Œī‰šī‰ŽīŠī‰‚ī‰‰īˆ ī‰Ĩī‰ĻīŠŠīˆ ī‹’ī‰ēī‰Šī‹„īŠģī‰īˆ ī‹…īŠŋī‰Ģī‹‹īˆ īˆ¨PulsesīˆŠīˆ īŠžī‹Œī‰šī‰ŽīŠī‰‚ī‰‰
                                                                          īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰
  $regfile = "m128def.dat"
  $crystal = 8000000                                               īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰
  '---------------------
  Config Portb.4 = Output
  Speaker Alias Portb.4                           īˆ  īˆ ī‹ī‰ī‹Œī‰ļīŠģī‰īˆ īˆ•īŠ¸īŠī‰īˆ ī‹‰ī‰•ī‰Ēī‰Ąīˆ īŠŸīˆ īŠŊī‰ĩī‹ŒīŠī‰īˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
  '---------------------
  Dim Pulses As Word , Periods As Word
  Dim I As Byte
                                                    īˆ  īˆ ī‰‚īˆšīˆ ī‹’ī‹Žī‹–ī‰ī‰Ļī‰Žī‰‰ī‹œī‰īˆ ī‹ī‹ŽīŠ´īŠģī‰īˆ ī‰Ĩī‰‚ī‹„ī‰­ī‰‡ī‹‹īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
  Pulses = 50 : Periods = 100
  '---------------------
  Sound Speaker , 100 , 200 : Wait 1

  Do
     Sound Speaker , Pulses , Periods
     Waitms 1
     Periods = Periods + 5                         īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰ī‰ī‹Œī‰ĩī‰ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™
  Loop Until Periods = 1000
                                                                    īˆ  īˆ īˆŽī‹’īŠ°īŠŧī‰ŽīŠ‹
  For I = 0 To 6                                                        īˆ  īˆ 
     Sound Speaker , 150 , 800
     Waitms 1000
  Next I

  Sound Speaker , 100 , 200
  End
                                                                                                   īˆ  īˆ 

                                                                                                   īˆ  īˆ 




  ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ           68                         ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
Practical Class 3                                                              Programming Microcontrollers

Exp.9: Generating DTMF Tones                                       īˆ  īˆ DTMFīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īˆēī‹’īŠ¨ī‰­ī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰


                                                                                       īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰
                          īˆ  īˆ īˆŽī‹ī‰ī‹Œī‰ļīŠģī‰īˆ ī‹‰ī‹Žī‰Šī‹„ī‰ŽīŠģī‰īˆ ī‰žī‰ī‰ĒīŠĢī‹ž DTMF (Dual Tone Multi Frequency) īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰
                                                                                       īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹




                    īˆ  īˆ 
                                                                                        īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ
                                               īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŠī‰šī‹‹ī‹‹īˆ .Jumperīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰ JP16īˆ īŠŊī‰ĩī‹ŒīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ
                                                                    īˆ  īˆ īˆŽī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠŸīˆ ī‰‚ī‹€īŠˇīˆ PB4,PB5īˆ īŠ”ī‰‰īˆ īŠŊī‰ĩī‹‹
                                                                                       īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą
                                              īˆ ī‰Ēī‹ˆīŠ¤ī‰īˆ  DTMFīˆ  ī‹‰ī‹Žī‰Šī‹„ī‰īˆ  ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ  ī‰Ļī‹ŽīŠģī‹Œī‰ŽīŠģīˆ  ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ  ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ  ī‹‚ī‹ŒīŠ´ī‹ƒīˆ  īŠ˛ī‹Œī‰­
                                                        īˆŽOC1Aīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ īŠŠīŠŋīˆ īŠŊī‰ĩī‹ŒīŠŋīˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹ī‰ī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠ‰īˆ ī‹“īŠŧīŠ§




Faculty of Electrical and Electronic Eng.             69                 Automatic Control & Automation Dept.
ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰                                                                            īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰

                                                                                           īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰
                    īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰                                  īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą
                                                                              īˆ  īˆ īˆŽīˆ¨OC1AīˆŠīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ī‹Œī‰ĩīˆ ī‰Ļī‹ŽīŠģī‹Œī‰
     Dtmfout Number , Duration                              īˆ  īˆ īˆŽī‰Ēī‰˛īŠ§īˆ ī‹’ī‰Žī‰ŽīŠģī‰īˆ īŠąī‰ī‰‚īˆšī‰īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹‚ī‰‚īŠŗī‰Šī‰ƒīˆ ī‰Ļī‰™ī‰ƒ :Number
īˆ    īˆ Dtmfout String , Duration                                       īˆ  īˆ īˆŽī‹’ī‹Žī‹ƒī‰‚ī‰‘īˆ ī‹īŠŧī‹ŽīŠī‰‚ī‰‰īˆ ī‹’ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‹…īŠŋī‰Ģīˆ īˆēDuration
                                                      īˆ  īˆ īˆŽī‹§ī‹ĩī‹īŠŋī‰‚īŠˇīˆ īŠžī‰‚ī‰ļī‰ī‹œī‰īˆ ī‹īŠŗī‰Šīˆ īŠŊīŠ¸ī‰˛ī‰īˆ īˆžīŠģī‰īˆ ī‹‚ī‰‚īŠŗī‰Šī‹žī‰īˆ ī‹’īŠ§ī‹Œī‹€īŠ‰īˆ īˆēString
                                                                                       īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰
    $regfile = "m128def.dat"
    $crystal = 8000000                                                          īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰
    '-------------------
    Enable Interrupts                                             īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ DTMFīˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹†ī‹žīˆ ī‰ī‰‚īŠ¨ī‰ŋī‰‚īŠ´īŠī‰īˆ īŠŊī‹ŽīŠ¨īŠ°ī‰
                                                                             īˆ  īˆ ī‰‚ī‹ˆīŠŧī‹€īŠ§īˆ īŠŸīˆ 1ī‰īŠŗī‹›īŠī‰
    '-------------------
    Dim Var As Byte
    Dim Btmp As Byte , Sdtmf As String * 10                      īˆ  īˆ ī‰‚īˆšīˆ ī‹’ī‹Žī‹–ī‰ī‰Ļī‰Žī‰‰ī‹œī‰īˆ ī‹ī‹ŽīŠ´īŠģī‰īˆ ī‰Ĩī‰‚ī‹„ī‰­ī‰‡ī‹‹īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰
    Sdtmf = "1234567890"
    '-------------------
    Do
       Dtmfout Sdtmf , 50
          Waitms 1000
                                                                īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰ī‰ī‹Œī‰ĩī‰ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™
       For Btmp = 0 To 15
          Dtmfout Btmp , 100
                                                                                 īˆ  īˆ īˆŽī‹’īŠ°īŠŧī‰ŽīŠ‹
          Waitms 500                                                                 īˆ  īˆ 
       Next Btmp
    Loop



    īˆ ī‰‚ī‹ˆī‹ƒī‰ƒīˆ ī‰‚ī‹€īŠˇīˆ ī‹’īŠ¨ī‰ŋī‰‚īŠ´īŠī‰īˆ īŠĒī‰‚īŠ¨ī‰ąīˆ īŠŊī‹ŽīŠ¨īŠ°ī‰īˆ ī‰‹īŠīˆ ī‰ī‰¨īŠģīˆ ī‰ī‰‚ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īŠŸīˆ 1ī‰īŠŗī‹›īŠī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ Dtmfoutīˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹†ī‰‡īˆ īˆē1ī‹’īŠ¤ī‰™ī‹īŠŋ
                                                           īˆ  īˆ īˆŽīŠĄīŠ´īŠ¯īˆ OC1Aīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ī‰‚ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Šī‰ī‰Ļī‰ĩī‰ˆī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‰Žī‰­

                                    .4MHZ ~ 8MHZīˆ īŠ”ī‰‰īˆ ī‹†ī‹ŒīŠ¸ī‹īˆ ī‹†ī‰ƒīˆ ī‰‹īŠīˆ īˆ ī‹īŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‰Ģī‰ī‰Ŧīˆšī‰īˆ ī‰Ĩī‰Ĩī‰Ēī‰īˆ ī‹†ī‰‡īˆ īˆē2ī‹’īŠ¤ī‰™ī‹īŠŋ

    īˆ ī‹Šī‰¨īˆšīˆ  ī‹’ī‹Žī‰šī‰‚ī‹ī‰ĒīŠģī‰īˆ  ī‰ī‰‚īŠŗī‹īŠ¨īŠģī‰īˆ  ī‹ī‹ˆīŠ°īŠģ Atmel application note (AN314)īˆ  ī‹’ī‹Žī‹„īŠ°īŠģī‰īˆ  ī‹’īŠ´ī‹Žī‰‘ī‹ŒīŠģī‰īˆ  ī‹’īŠ¨ī‰•ī‰ī‰ĒīŠŋīˆ  ī‹•ī‰‚ī‰•ī‰ĒīŠģī‰īˆ  īˆē3ī‹’īŠ¤ī‰™ī‹īŠŋ
                                                                                                     īˆ  īˆ  īˆŽī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰




    ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ                      70                         ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ

Weitere ähnliche Inhalte

Andere mochten auch

Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5AL-AWAIL for Electronic Engineering
 

Andere mochten auch (9)

Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
 

Ähnlich wie Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3

CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧ
CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧCoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧ
CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧyamakiyoslides
 
Metasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoKiwamu Okabe
 
Camping: Going off the Rails with Ruby
Camping: Going off the Rails with RubyCamping: Going off the Rails with Ruby
Camping: Going off the Rails with RubyEleanor McHugh
 
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan WanCODE BLUE
 
Snake Game on FPGA in Verilog
Snake Game on FPGA in VerilogSnake Game on FPGA in Verilog
Snake Game on FPGA in VerilogKrishnajith S S
 
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...Antoine Savine
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksJinTaek Seo
 
how to hack with pack and unpack
how to hack with pack and unpackhow to hack with pack and unpack
how to hack with pack and unpackDavid Lowe
 
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open SourceHazelcast
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Tom Paulus
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016PVS-Studio
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with ClangSamsung Open Source Group
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assemblyJarek Ratajski
 
Ki2518101816
Ki2518101816Ki2518101816
Ki2518101816IJERA Editor
 
Ki2518101816
Ki2518101816Ki2518101816
Ki2518101816IJERA Editor
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework HelpC++ Homework Help
 
Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5SAP Concur
 
Building a Big Data Machine Learning Platform
Building a Big Data Machine Learning PlatformBuilding a Big Data Machine Learning Platform
Building a Big Data Machine Learning PlatformCliff Click
 

Ähnlich wie Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3 (20)

CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧ
CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧCoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧ
CoqãĢã‚ˆã‚‹æš—åˇã‚ĸãƒĢゴãƒĒã‚ēムぎ原čŖ…ぎ厉全性検č¨ŧ
 
Metasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on Arduino
 
srm suite webinar
srm suite webinarsrm suite webinar
srm suite webinar
 
Camping: Going off the Rails with Ruby
Camping: Going off the Rails with RubyCamping: Going off the Rails with Ruby
Camping: Going off the Rails with Ruby
 
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
 
Snake Game on FPGA in Verilog
Snake Game on FPGA in VerilogSnake Game on FPGA in Verilog
Snake Game on FPGA in Verilog
 
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...
Practical Implementation of AAD by Antoine Savine, Brian Huge and Hans-Jorgen...
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
how to hack with pack and unpack
how to hack with pack and unpackhow to hack with pack and unpack
how to hack with pack and unpack
 
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open Source
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
Ki2518101816
Ki2518101816Ki2518101816
Ki2518101816
 
Ki2518101816
Ki2518101816Ki2518101816
Ki2518101816
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5Unlocking Your Hadoop Data with Apache Spark and CDH5
Unlocking Your Hadoop Data with Apache Spark and CDH5
 
Building a Big Data Machine Learning Platform
Building a Big Data Machine Learning PlatformBuilding a Big Data Machine Learning Platform
Building a Big Data Machine Learning Platform
 

KÃŧrzlich hochgeladen

80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...
80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...
80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 

KÃŧrzlich hochgeladen (20)

80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...
80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...
80 Đáģ€ THI THáģŦ TUYáģ‚N SINH TIáēžNG ANH VÀO 10 Sáģž GD – ĐT THÀNH PHáģ Háģ’ CHÍ MINH NĂ...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3

  • 1. ī„ ī„  ī„  ī„ ī†Šī…šī…°ī…Ĩī…Ŋī…ģī…ī„ ī…Œī…‚ī…Ŋī…šī…’ī…‹ī…Ŋī…ģī…ī„ ī†Ēī…ī…Ŋī…šī…‰ â€ĢīēīģŸīē˜īē īēŽīē­īē īēīģŸīģŒīģ¤īģ īģ´īē”â€Ŧ ī„  ī„ ī†Ēī…ī…ģī…‚ī…ī…ģī…ī„ ī†Ēī…Ąī…ģī…ī…ģī… ī„ ī„  ī„ ī„  Programming Embedded Systems Microcontroller You Can Practice Microcontroller Programming Easily Now! WALID BALID, Tuesday, December 15, 2009
  • 2. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ Exp.5: Hexadecimal Array Keypad īˆ  īˆ ī‹’ī‹ŽīŠ¯ī‹ŒīŠ°ī‰ļīŠŋīˆ ī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ īˆēī‹’ī‰ŽīŠŋī‰‚īŠˆī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰ īˆ  īˆ īˆŽī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰ īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹ īˆ  īˆ  īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą īˆ ī‹‘ī‰¨īŠ¯ī‰‚ī‹„īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹ī‰­ī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋī‹‹īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹’īŠ¯ī‰ĒīŠ¨īŠŋī‹‹īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠ´īŠģīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­ īˆ  īˆ īˆŽī‹’ī‹ŽīŠŧī‰ŽīŠŧī‰Žī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ īˆēīŠ”ī‰Žī‹Žī‰­ī‰‚ī‰­ī‰ƒīˆ īŠ”ī‰Žī‹Žī‹€ī‹ŽīŠŧīŠ¨ī‰īˆ īŠ•ī‰‡īˆ ī‰˜ī‰‚ī‰ŽīŠīˆ ī‰‚ī‹„ī‹ƒī‰ˆīŠ¯īˆ ī‹’ī‹ī‰Ēī‰˛īŠ§īˆ ī‰ī‰­īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗīˆ īŠŊī‰•ī‰ƒīˆ ī‹…īŠŋ īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą īˆ īˆ—ī‰Ąī‰„ī‰ŽīŠģī‰īˆ ī‹…īŠŋī‰Ģīˆ īŠąī‹ī‰ĒīŠ¨ī‰ī‹‹īˆ  ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ īŠžī‹Œī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ īˆ  īˆ Config Kbd = Portb , Delay = 150 īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°ī‹€īŠŧīŠģīˆ ī‹’ī‹ŽīŠ¸ī‹Žī‹ƒī‰‚īŠ¸ī‹ŽīŠī‰īˆ ī‹’īŠģī‰‚ī‹ąīŠ¨īŠģī‰īˆ ī‰Ēī‰‘ī‰ƒīˆ ī‹ī‰Ĩī‰‚īŠ°ī‰ŽīŠģ īˆ  īˆ īˆēī‹‰ī‹ƒī‰ƒīˆ ī‰“ī‹Žī‰™īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗ īˆ ī‹…īŠ¸ī‹īˆ  īˆ…īˆ  ī‰ī‰§ī‰‡īˆ  Var = 16īˆ  ī‹’ī‹€ī‹ŽīŠ´īŠģī‰‚ī‰‰īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ  ī‹Šī‰¨ī‹‡īˆ  ī‰Ĩī‹ŒīŠ¨ī‰Žī‰­ īˆ  īˆ­1 īˆ  īˆ Var = Getkbd() īˆŽīŠĸī‹ŒīŠŦī‰ēīŠŋīˆ ī‰ ī‰‚ī‰ŽīŠ°īŠŋīˆ ī‹ī‰ƒīˆ īŠēī‰‚ī‹„ī‹‡ īˆ īŠŊīŠ¸ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ  īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹’ī‹€ī‹ŽīŠ´ī‰‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹Šī‰¨ī‹‡īˆ ī‰Ĩī‹ŒīŠ¨ī‰Žī‰­ īˆ  īˆ­ 2 īˆ  īˆ  īˆēī‹īŠģī‰‚ī‰ŽīŠģī‰ ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 58 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 3. Practical Class 3 Programming Microcontrollers S1 = 0 S2 = 1 S3 = 2 S4 = 4 S5 = 5 S6 = 6 S7 = 8 S8 = 9 S9 = 10 S* = 12 S0 = 13 S# = 14 A=3 B=7 C = 11 D = 15 īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰ $regfile = "m128def.dat" $crystal = 1000000 īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰ $baud = 4800 '----------------------- Config Kbd = Portb , Delay = 150 īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ '----------------------- Dim Var As Byte īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ '----------------------- Do Var = Getkbd() If Var < 16 Then Gosub Check_number īˆ  īˆ īˆŽī‰œī‹Žī‰ī‰‚īŠ°īŠī‰īˆ ī‹’īŠģī‰‚ī‰™īˆ ī‹‘ī‹•ī‰ī‰ĒīŠŗīˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™ End If īˆ  īˆ  Loop End '----------------------- Check_number: Select Case Var Case 0 : Print "Key Pressed is (1)" Case 1 : Print "Key Pressed is (2)" Case 2 : Print "Key Pressed is (3)" Case 3 : Print "Key Pressed is (A)" Case 4 : Print "Key Pressed is (4)" Case 5 : Print "Key Pressed is (5)" Case 6 : Print "Key Pressed is (6)" Case 7 : Print "Key Pressed is (B)" īˆ ī‹ī‰‘īˆ īŠĸī‹ŒīŠŦī‰ēīŠī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰‚ī‰‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋīˆ ī‹īŠ§ī‰ĒīŠ°īŠģīˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰ Case 8 : Print "Key Pressed is (7)" Case 9 : Print "Key Pressed is (8)" īˆ  īˆ īˆŽī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ īŠ•ī‰‡īˆ ī‹‘ī‰Ĩī‹ŒīŠ¨īŠģī‰ Case 10 : Print "Key Pressed is (9)" Case 11 : Print "Key Pressed is (C)" Case 12 : Print "Key Pressed is (*)" Case 13 : Print "Key Pressed is (0)" Case 14 : Print "Key Pressed is (#)" Case 15 : Print "Key Pressed is (D)" End Select Return '----------------------- Faculty of Electrical and Electronic Eng. 59 Automatic Control & Automation Dept.
  • 4. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ Exp.6: Programming LCD īˆ  īˆ ī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰īˆ īˆēī‹’ī‰­ī‰Ĩī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰ īˆ  īˆ īˆŽ20x4īˆ ī‹’ī‹ŽīŠ¯ī‰ĒīŠŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰ īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹ īˆ  īˆ  īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ īˆ  īˆ īˆŽSW2īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą īˆ ī‰žī‰ī‰ĒīŠ¨ī‰Žī‰­ī‰īˆ  īŠ•ī‰‡īˆ  ī‹’īŠ¯ī‰‚ī‰šī‹ĸī‰‚ī‰‰īˆ  ī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠˇīˆ  ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ  ī‹’ī‰ąī‰‚ī‰ąīˆ  ī‹“īŠŧīŠ§īˆ  ī‹’ī‹Žī‰ļī‹ƒīˆ  īŠ˛ī‰Šī‰‚īŠŠīˆ  ī‰Šī‰‚ī‹ˆīŠŖī‹ĸīˆ  ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ  ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ  ī‹‚ī‹ŒīŠ´ī‹ƒīˆ  īŠ˛ī‹Œī‰­ īˆ  īˆ īˆŽī‹’ī‹ŽīŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰‚ī‰‰īˆ ī‹’ī‰ĩī‰‚īŠˆī‰īˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰ īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 īˆ  īˆ īˆ’ī‰‚īŠ¨īŠī‰īˆ īŠŠīŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Œī‰‚ī‹ąīŠŗī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Db7 = Portc.7 ,ī„ ī„ ī„ ī„ ī„ E = Portc.2 , Rs = Portc.3 Config Lcd = 20 * 4 īˆ  īˆ īˆ¨ī‰Ēī‹ąī‰­ī‰ƒīˆ īˆĒīˆ ī‹‘ī‰Ļī‹€īŠ§ī‰ƒīˆŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Ĩī‰‚īŠ¨ī‰‰ī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Deflcdchar 0 , 14 , 17 , 14 , 17 , 17 , 14 , 17 , 14 LCD Designerīˆ ī‹‘ī‰ī‰Ĩī‹žī‰īˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ īŠŸī‰‚ī‰šī‰‡īˆ īŠ˛ī‰ĒīŠŠīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Cls īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰œī‰ŽīŠŋ ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 60 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 5. Practical Class 3 Programming Microcontrollers Lcd var īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹“īŠŧīŠ§īˆ īŠ˛ī‰ĒīŠŠ/ī‹’ī‹€ī‹ŽīŠŗīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Lowerline īˆ  īˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠšī‹ī‰ĒīŠ„ Shiftlcd Right īˆ  īˆ īˆ īŠ”ī‹€ī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‹‘ī‰Ēī‹ˆīŠ¤īŠī‰īˆ ī‰ī‰‚īŠŋī‹ŒīŠŧīŠ¨īŠī‰īˆ īŠŠī‹ŽīŠšīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡ Shiftlcd Left īˆ  īˆ īˆ ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‹‘ī‰Ēī‹ˆīŠ¤īŠī‰īˆ ī‰ī‰‚īŠŋī‹ŒīŠŧīŠ¨īŠī‰īˆ īŠŠī‹ŽīŠšīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡ Locate X , Y īˆ  īˆ īˆ¨ī‰Ĩī‹Œī‹€īŠ§/ī‰Ēī‹ąī‰­īˆŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹Œī‰ Shiftcursor Right īˆ  īˆ īŠ”ī‹€ī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ļī‰™ī‰ī‹‹īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡ Shiftcursor Left īˆ  īˆ ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰īˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ļī‰™ī‰ī‹‹īˆ ī‹ĩī‰ī‰Ĩī‹Œī‹€īŠ§īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹’ī‰™ī‰ī‰Ģī‰‡ Home Upper īˆ  īˆ īˆ¨ī‹’ī‹ī‰ī‰Ļī‰ŠīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆŠīˆ īŠžī‹‹ī‹žī‰īˆ ī‰Ĩī‹Œī‹€īŠ¨īŠģī‰/ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰ Cursor Off Noblink īˆ  īˆ īˆŽī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ ī‹•ī‰‚īŠŦīŠģī‰‡ Cursor On Blink īˆ  īˆ ī‹†ī‰‚īŠ´īŠ°ī‰Ąīˆ īŠŠīŠŋīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŊī‹ŽīŠŦī‰˛ī‰ Display Off īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹•ī‰‚īŠ°ī‰ŋī‰‡ Display On īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŊī‹ŽīŠŦī‰˛ī‰ Thirdline īˆ  īˆ ī‰“īŠģī‰‚ī‰’īŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰ Fourthline īˆ  īˆ īŠŠī‰‰ī‰ī‰ĒīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ īŠ•ī‰‡īˆ īŠžī‰‚īŠ´ī‰Žī‹ƒī‹œī‰ Home Third īˆ  īˆ ī‰“īŠģī‰‚ī‰’īŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹‹ Home Fourth īˆ  īˆ īŠŠī‰‰ī‰ī‰ĒīŠģī‰īˆ ī‰Ēī‹ąī‰ŽīŠģī‰īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ īŠŸīˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸īŠģī‰īˆ ī‰Ēī‰ąī‹›īŠŋīˆ īŠŠī‰šī‹‹ Lcd Chr(x) īˆ  īˆ īŠŸī‰‚ī‰šī‹ĸī‰īˆ īŠ˛ī‰Ēīˆī‰īˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰ $regfile = "m128def.dat" īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰ $crystal = 8000000 '----------------------- īˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰Œī‰‚ī‹ąīŠŗī‰ƒīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.3 īˆ  īˆ īˆŽī‹īŠ¸ī‰šī‰ŽīŠī‰īˆ īŠŠīŠŋ īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠ¤īŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŊī‹ī‰Ĩī‹ŒīŠŋīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Config Lcd = 20 * 4 īˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‹’ī‹ŽīŠ¯ī‰‚ī‰šī‰‡īˆ īŠ˛ī‰Šī‰‚īŠŠīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Deflcdchar 0 , 14 , 17 , 14 , 17 , 17 , 14 , 17 , 14 Deflcdchar 1 , 17 , 14 , 17 , 14 , 14 , 17 , 14 , 17 LCD Designerīˆ ī‹‘ī‰ī‰Ĩī‹žī‰ '----------------------- īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ Dim A As Byte '----------------------- Do Cls Lcd "hello world!" Wait 1 īˆ  īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™ īˆ  īˆ īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ  Lowerline Wait 1 īˆ  īˆ īˆ ī‹’ī‹Žī‰­ī‰‚ī‰­ī‹žīˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰īˆ ī‰žī‰ĒīŠ§ī‹‹ īˆ  īˆ īˆŽī‹’ī‹ŽīŠ¯ī‰‚ī‰šī‹ĸī‰īˆ īŠ˛ī‰Šī‰‚īˆī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡ī‹‹ Lcd "LCD Test" Wait 1 For A = 1 To 8 Shiftlcd Right Faculty of Electrical and Electronic Eng. 61 Automatic Control & Automation Dept.
  • 6. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ Waitms 500 Next A For A = 1 To 8 Shiftlcd Left Waitms 500 Next A Locate 2 , 9 Lcd "-L2,C9" Wait 1 Shiftcursor Right Lcd "-*-" Wait 1 Shiftcursor Left Lcd "*-*" Wait 1 Home Upper Lcd "HELLO WORLD" Wait 1 Cursor Off Noblink Wait 1 Cursor On Blink Wait 1 Display Off Wait 1 Display On Wait 1 Thirdline Lcd " /Line 3" Wait 1 Fourthline Lcd " /Line 4" Wait 1 Home Third Lcd ":)" Wait 1 Home Fourth Lcd ":(" Wait 1 Cls Locate 1 , 9 : Lcd Chr(0) Wait 1 Locate 1 , 11 : Lcd Chr(1) Loop End ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 62 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 7. Practical Class 3 Programming Microcontrollers Exp.7: Programming Graphic LCD īˆ  īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰īˆ īˆēī‹’īŠ¨ī‰‰ī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰ īˆ  īˆ īˆŽ128x64īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’īŠ‰ī‰Ēī‰‰ī‹‹īˆ īŠŊī‹Žī‰ĩī‹Œī‰ īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹ īˆ  īˆ  īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ īˆ  īˆ īˆŽSW3īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą īˆ īŠ•ī‰‡īˆ ī‹’īŠ¯ī‰‚ī‰šī‹ĸī‰‚ī‰‰īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹“īŠŧīŠ§īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰Šīˆ ī‰ī‰ī‹•ī‰‚ī‰˛ī‹ƒī‰‡ī‹‹īˆ ī‰Šī‹Œī‰ĩī‹‹īˆ ī‹’ī‹Žī‰ļī‹ƒīˆ īŠ˛ī‰Šī‰‚īŠŠīˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­ īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰‚ī‰‰īˆ ī‹’ī‰ĩī‰‚īŠˆī‰īˆ ī‰ī‰‚īŠˇī‰ĒīŠ‡ī‰īˆ ī‰žī‰ī‰ĒīŠ¨ī‰Žī‰­ī‰ īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą Config Graphlcd = 128 * 64sed , Dataport= Porta, Controlport= Portc , Ce = 2 , Ce2 = 4 , Cd = 7 , Rd = 6 , īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ īŠŠīŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‰Œī‰‚ī‹ąīŠŗī‹žī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ īˆ  īˆ Reset = 3 , Enable = 5 īˆ  īˆ $lib "glcdKS108.lib" īˆ  īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹’ī‰Šī‰ŽīŠ¸īŠŋīˆ īŠąī‹ī‰ĒīŠ¨ī‰ Faculty of Electrical and Electronic Eng. 63 Automatic Control & Automation Dept.
  • 8. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ Setfont Font īˆ  īˆ ī‹‰īŠŋī‰ī‰Ļī‰ĸī‰Žī‰­ī‰īˆ ī‰Ĩī‰ī‰ĒīŠī‰īˆ īŠĄīŠˆī‰īˆ īŠ”ī‹ŽīŠ¨ī‰ Cls īˆ  īˆ ī‹‚ī‹Œī‰­ī‰ĒīŠģī‰ī‹‹īˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰œī‰ŽīŠŋ Cls Text īˆ  īˆ īŠĄīŠ´īŠ¯īˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰œī‰ŽīŠŋ Cls Graph īˆ  īˆ īŠĄīŠ´īŠ¯īˆ ī‹‚ī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰œī‰ŽīŠŋ Lcdat y , x , var [, inv] īˆ  īˆ īˆŽī‰Ĩī‰ĻīŠŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹’ī‰ąī‰‚ī‰˛īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ˇī‹ƒīˆ ī‹‹ī‰ƒīˆ īŠžī‹Œī‰šī‰ŽīŠŋīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Line(X0 , Y0) - (X1 , Y1) , Color īˆ  īˆ ī‹’ī‹ī‰‚ī‹ˆī‹ƒīˆ ī‹’ī‹ąīŠ´ī‹ƒī‹‹īˆ ī‹’ī‹ī‰ī‰Ļī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠ•ī‰‡īˆ ī‹ĩī‰ī‰Ĩī‰‚ī‹„ī‰Žī‰­ī‰īˆ īŠĄī‰Ąīˆ ī‹ī‰­ī‰Š Pset X , Y , Color īˆ  īˆ īˆ¨SET/RST PixelīˆŠīˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ ī‹•ī‰‚īŠ°ī‰Ąī‰‡īˆ ī‹‹ī‰ƒīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰ˆī‰‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰ Circle(X , Y) , r , Color rīˆ ī‰Ēī‹ąīŠ´ī‰‰ī‹‹īˆ ī‹’ī‹ŽīŠ¨ī‰•ī‰ĒīŠŋīˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŸīˆ ī‹‘ī‰Ēī‹–ī‰ī‰Ĩīˆ ī‹ī‰­ī‰Š Showpic X , Y , label īˆ  īˆ ī‹‘ī‰Ĩī‰ĻīŠŠīˆ ī‹’ī‰ŽīŠ¯ī‹œīˆ ī‰Ļī‹„īŠ§īˆ ī‹‘ī‰Ĩī‹Œī‰•ī‹ŒīŠŋīˆ ī‰Ĩī‰ĻīŠŠīˆ īŠŠīŠŗī‹ŒīŠŋīˆ īŠŸīˆ ī‹‘ī‰Šī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡ $include "Font5x8.font" īˆ  īˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ īŠĸī‹Œī‹ąī‰Ąīˆ īŠąīŠŧīŠŋīˆ ī‹…īŠŋīˆ īŠĸī‹Œī‹ąīŠˆī‰īˆ īŠąīŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰ $bgf "Smiley1.bgf" īˆ  īˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ bgfīˆ īŠąīŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠ”ī‹€ī‰ēī‰ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰ $regfile = "m128def.dat" $crystal = 8000000 īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰ $lib "glcdKS108.lib" '------------------------- Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 2 , Ce2 = 4 , Cd = 7 , Rd = 6 , Reset = 3 , īˆ  īˆ īˆŽī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰‚ī‹ˆīŠ¨īŠŋīˆ ī‹’īŠŧī‰ĩī‹ŒīŠī‰īˆ ī‹’ī‰‰ī‰ī‹Œī‰ŠīŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ Enable = 5 '------------------------- Dim X As Byte , Y As Byte īˆ  īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ '------------------------- Cls : Cls Text : Cls Graph īˆ  īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‰œī‰ŽīŠŋ '------------------------- Setfont Font8x8 Lcdat 3 , 11 , "Font 5x8 Test" Lcdat 4 , 11 , "Font 6x8 Test" 8x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Lcdat 5 , 11 , "Font 8x8 Test" Wait 2 Cls Setfont Font5x8 īˆ  īˆ 5x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Lcdat 1 , 1 , "LINE1" : Wait 1 Lcdat 2 , 1 , "LINE2" : Wait 1 Lcdat 3 , 1 , "LINE3" : Wait 1 Setfont Font6x8 Lcdat 4 , 1 , "LINE4" : Wait 1 īˆ  īˆ 6x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Lcdat 5 , 1 , "LINE5" : Wait 1 Lcdat 6 , 1 , "LINE6" : Wait 1 Setfont Font8x8 Lcdat 7 , 1 , "LINE7" : Wait 1 īˆ  īˆ 8x8īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ Lcdat 8 , 1 , "LINE8" : Wait 1 '/------------/ Cls Setfont Font16x16 īˆ  īˆ 16x16īˆ ī‹ī‰–īŠ‡ī‰īˆ ī‹…īŠŋīˆ īŠĄī‰Ąīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰īˆ ī‰¸ī‹Œī‰ļī‹ƒīˆ ī‹’īŠ§ī‰‚ī‰Šī‰ŋ ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 64 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 9. Practical Class 3 Programming Microcontrollers Lcdat 4 , 23 , "16x16" : Wait 2 Cls Lcdat 1 , 1 , "LINE1" : Wait 1 Lcdat 3 , 1 , "LINE2" : Wait 1 Lcdat 5 , 1 , "LINE3" : Wait 1 Lcdat 7 , 1 , "LINE4" : Wait 1 '/------------/ Setfont Font8x8 Lcdat 4 , 11 , "Drawing Lines" : Wait 2 Cls Text ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰˛īŠģīˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰īˆ ī‹ī‹Žī‰ŽīŠ´ī‰ŽīŠģī‰īˆ īŠĩīŠ¯ī‹‹īˆ īŠĸī‹Œī‹ąī‰Ąīˆ ī‹ī‰­ī‰Š Line(0 , 0) -(127 , 0) , 255 Y 63,31 Wait 1 127,0 Line(0 , 63) -(127 , 63) , 255 0,0 Wait 1 Line(0 , 0) -(0 , 63) , 255 Wait 1 Line(127 , 0) -(127 , 63) , 255 Wait 1 127,63 0,63 Line(0 , 0) -(127 , 63) , 255 īˆ  īˆ  X Wait 1 Cls Graph īˆ  īˆ  '/------------/ Lcdat 4 , 11 , "SET/RST Pixel" : Wait 2 Cls Text For X = 0 To 127 Pset X , 20 , 255 Pset X , 43 , 255 Waitms 200 Next X For Y = 0 To 63 Pset 42 , Y , 255 Pset 86 , Y , 255 Waitms 200 Next Y For X = 127 To 0 Step -1 Pset X , 20 , 0 Pset X , 43 , 0 Waitms 200 Next X īˆ  īˆ īˆ ī‹’ī‹ąīŠ´ī‹„ī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠĸī‹Œī‹ąī‰Ąīˆ ī‹ī‰­ī‰Š īˆ  īˆ ī‹’ī‹ąīŠ´ī‹„ī‰‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ ī‰‚ī‹ˆī‰šī‰ŽīŠŋīˆ ī‹ī‰‘īˆ ī‹…īŠŋī‹‹ For Y = 63 To 0 Step -1 Pset 42 , Y , 0 Pset 86 , Y , 0 Waitms 200 Next X Cls Graph '/------------/ Lcdat 4 , 11 , "Drawing Circle" : Wait 2 Cls Graph For X = 1 To 31 ī‹‘ī‰Ēī‹–ī‰ī‰Ĩīˆ ī‹ī‰­ī‰Š Circle(63 , 31) , X , 255 Waitms 200 Circle(63 , 31) , X , 0 Next X īˆ  īˆ  Faculty of Electrical and Electronic Eng. 65 Automatic Control & Automation Dept.
  • 10. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ Cls Graph īˆ  īˆ  '/------------/ Showpic 0 , 0 , Smiley1 Wait 2 Cls : Cls Text : Cls Graph Showpic 0 , 0 , Smiley2 Wait 2 Cls Graph īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹’ī‹„ī‹€ī‰ēīŠī‰īˆ ī‰Šī‹Œī‰ļīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‰‡ Showpic 0 , 0 , Smiley3 Wait 2 Cls Graph Showpic 0 , 0 , Smiley4 Wait 2 '/------------/ Glcdcmd &H3E , 1 : Glcdcmd &H3E , 2 īˆ  īˆ ī‹ī‰Šī‰‚ī‰Žī‹ŽīŠģī‰ī‹‹īˆ īˆŸī‹Žī‹€ī‹ŽīŠģī‰īˆ ī‹’ī‹ŽīŠŋī‹Œī‰­ī‰ĒīŠģī‰īˆ ī‰Šī‰‚ī‹ˆīŠŖī‹ĸī‰īˆ ī‹’ī‰ąī‰‚ī‰ąīˆ ī‹ī‹€ī‰ŽīŠŗīˆ ī‹•ī‰‚īŠ°ī‰ŋī‰‡īˆ  īˆ­ Wait 1 Glcdcmd &H3F , 1 : Glcdcmd &H3F , 2 īˆ  īˆ īŠ”ī‹€ī‰ŽīŠ´īŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‹‘ī‰Ĩī‰‚īŠ§ī‰‡īˆ īˆ  īˆ­ '/------------/ End '------------------- $include "Font5x8.font" $include "Font6x8.font" īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹’ī‹ŽīŠ‰ī‰Ēī‰‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‰¸ī‹Œī‰ļī‹„īŠģī‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ $include "Font8x8.font" $include "Font16x16.font" '------------------- Smiley1: $bgf "Smiley1.bgf" Smiley2: $bgf "Smiley2.bgf" īˆ  īˆ ī‹’ī‹Žī‰•ī‰Šī‰‚ī‰Ąīˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ ī‹…īŠŋīˆ ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‰Šī‹Œī‰ļīŠģī‰īˆ ī‰ī‰‚īŠ°īŠŧīŠŋīˆ īŠ”ī‹€ī‰ēī‰ Smiley3: $bgf "Smiley3.bgf" Smiley4: $bgf "Smiley4.bgf" īˆ  īˆ īˆ  ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 66 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 11. Practical Class 3 Programming Microcontrollers Exp.8: Generating Tones īˆ  īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īˆēī‹’ī‹„īŠŋī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰ īˆ  īˆ īˆŽī‹ī‰ī‹Œī‰ļīŠģī‰īˆ ī‹‰ī‹Žī‰Šī‹„ī‰ŽīŠģī‰īˆ ī‰žī‰ī‰ĒīŠĢī‹žīˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰ īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹ īˆ  īˆ  īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŠī‰šī‹‹ī‹‹īˆ .Jumperīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰ JP16īˆ īŠŊī‰ĩī‹ŒīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ īˆ  īˆ īˆŽī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠŸīˆ ī‰‚ī‹€īŠˇīˆ PB4,PB5īˆ īŠ”ī‰‰īˆ īŠŊī‰ĩī‹‹ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą īˆ ī‹“īŠŧīŠ§īˆ ī‰Ēī‹ˆīŠ¤ī‰īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‹‰ī‹Žī‰Šī‹„ī‰īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰ŽīŠģīˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‹ƒīˆ īŠ˛ī‹Œī‰­ īˆ ī‰—īŠŋī‰Ĩīˆ īŠžī‹ī‰Ąīˆ ī‹…īŠŋīˆ ī‹’ī‹€īŠŦī‹ƒīˆ ī‹ī‰ƒīˆ īŠŊī‹ŽīŠ¸ī‰˛ī‰īˆ ī‹…īŠ¸īŠ™īˆ īˆŽī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹ī‰ī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠ‰ īˆ ī‰žī‰ĒīŠ§īˆ īˆ—ī‹ŽīŠŦī‰ī‹‹īˆ ī‹’ī‰ēī‰Šī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ īˆžīŠģī‰īˆ  soundīˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰īˆ ī‹‘ī‰ĻīŠ§ īˆ  īˆ īˆ¨SpeakerīˆŠīˆ ī‹ī‰•ī‰Šī‰‚īŠˆī‰īˆ ī‰Šī‰‚ī‹ˆīˆ‘ī‰‚ī‰‰īˆ ī‹īŠ¸ī‰šī‰Žī‹īˆ ī‹ī‰¨īŠģī‰īˆ ī‹ī‰Šī‹Œī‰Žī‰­ī‰Ŧī‹ƒī‰īˆ–īŠģī‰īˆ ī‰ ī‰‚ī‰ŽīŠ°īŠī‰īˆ ī‹‘ī‰ĻīŠ§ī‰‚īŠŗīˆ ī‹“īŠŧīŠ§īˆ ī‰Ĩī‰Ĩīˆ–īŠģī‰īˆ īˆ—īŠŦī‰Žī‹īˆ ī‹īŠģī‰‚ī‰ŽīŠģī‰‚ī‰‰ī‹‹īˆ ī‹’ī‰ēī‰Šī‹„īŠģī‰īˆ ī‰Šī‹‹ī‰Ĩī‹‹ Faculty of Electrical and Electronic Eng. 67 Automatic Control & Automation Dept.
  • 12. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą īˆ ī‰Ĩī‰ĻīŠŠīˆ  ī‹’ī‰ēī‰Šī‹ƒīˆ  ī‰žī‰ĒīŠ¨ī‰‰ī‹‹īˆ  īˆ¨SpeakerīˆŠīˆ  ī‰‹ī‹ąīŠ´īŠģī‰īˆ  ī‹“īŠŧīŠ§īˆ  ī‰ī‹Œī‰ĩīˆ  ī‰Ļī‹ŽīŠģī‹Œī‰ īˆ  īˆ Sound Speaker , Pulses , Periods īˆ  īˆ īˆŽīˆ¨PeriodsīˆŠīˆ īŠžī‹Œī‰šī‰ŽīŠī‰‚ī‰‰īˆ ī‰Ĩī‰ĻīŠŠīˆ ī‹’ī‰ēī‰Šī‹„īŠģī‰īˆ ī‹…īŠŋī‰Ģī‹‹īˆ īˆ¨PulsesīˆŠīˆ īŠžī‹Œī‰šī‰ŽīŠī‰‚ī‰‰ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰ $regfile = "m128def.dat" $crystal = 8000000 īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰ '--------------------- Config Portb.4 = Output Speaker Alias Portb.4 īˆ  īˆ ī‹ī‰ī‹Œī‰ļīŠģī‰īˆ īˆ•īŠ¸īŠī‰īˆ ī‹‰ī‰•ī‰Ēī‰Ąīˆ īŠŸīˆ īŠŊī‰ĩī‹ŒīŠī‰īˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ '--------------------- Dim Pulses As Word , Periods As Word Dim I As Byte īˆ  īˆ ī‰‚īˆšīˆ ī‹’ī‹Žī‹–ī‰ī‰Ļī‰Žī‰‰ī‹œī‰īˆ ī‹ī‹ŽīŠ´īŠģī‰īˆ ī‰Ĩī‰‚ī‹„ī‰­ī‰‡ī‹‹īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ Pulses = 50 : Periods = 100 '--------------------- Sound Speaker , 100 , 200 : Wait 1 Do Sound Speaker , Pulses , Periods Waitms 1 Periods = Periods + 5 īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰ī‰ī‹Œī‰ĩī‰ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™ Loop Until Periods = 1000 īˆ  īˆ īˆŽī‹’īŠ°īŠŧī‰ŽīŠ‹ For I = 0 To 6 īˆ  īˆ  Sound Speaker , 150 , 800 Waitms 1000 Next I Sound Speaker , 100 , 200 End īˆ  īˆ  īˆ  īˆ  ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 68 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ
  • 13. Practical Class 3 Programming Microcontrollers Exp.9: Generating DTMF Tones īˆ  īˆ DTMFīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īˆēī‹’īŠ¨ī‰­ī‰‚ī‰ŽīŠģī‰īˆ ī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰ īˆ  īˆ īˆēī‹’ī‰‰ī‰Ēī‰–ī‰ŽīŠģī‰īˆ ī‹…īŠŋīˆ ī‹’ī‹ī‰‚īŠŦīŠģī‰ īˆ  īˆ īˆŽī‹ī‰ī‹Œī‰ļīŠģī‰īˆ ī‹‰ī‹Žī‰Šī‹„ī‰ŽīŠģī‰īˆ ī‰žī‰ī‰ĒīŠĢī‹ž DTMF (Dual Tone Multi Frequency) īˆ ī‹’ī‹Žī‰ī‹Œī‰ĩīˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰ īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰ŽīŠģī‰īˆ īŠĄī‹ąīŠ‹ īˆ  īˆ  īˆ  īˆ īˆēīŠŊī‹Žī‰ĩī‹Œī‰īˆ ī‰ī‰‚ī‰ŠīŠŧī‹ąī‰ŽīŠŋ īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠŠī‰šī‹‹ī‹‹īˆ .Jumperīˆ ī‹‚ī‰ī‰Ļī‰ĸī‰Žī‰­ī‰‚ī‰‰ JP16īˆ īŠŊī‰ĩī‹ŒīŠģī‰īˆ ī‹’ī‹ąīŠ´ī‹ƒīˆ īŠļī‹īŠĢī‰‡īˆ ī‰‹īŠ īˆ  īˆ īˆŽī‹‘ī‰Šī‹Œī‰ļīŠģī‰īˆ īŠŸīˆ ī‰‚ī‹€īŠˇīˆ PB4,PB5īˆ īŠ”ī‰‰īˆ īŠŊī‰ĩī‹‹ īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹€īŠ§īˆ ī‰ ī‰Ēī‰ą īˆ ī‰Ēī‹ˆīŠ¤ī‰īˆ  DTMFīˆ  ī‹‰ī‹Žī‰Šī‹„ī‰īˆ  ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ  ī‰Ļī‹ŽīŠģī‹Œī‰ŽīŠģīˆ  ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰īˆ  ī‹’ī‰‰ī‰‚ī‰ŽīŠ¸ī‰‰īˆ  ī‹‚ī‹ŒīŠ´ī‹ƒīˆ  īŠ˛ī‹Œī‰­ īˆŽOC1Aīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ īŠŠīŠŋīˆ īŠŊī‰ĩī‹ŒīŠŋīˆ ī‹ī‰•ī‰Šī‰‚ī‰Ąīˆ ī‹ī‰ī‹Œī‰ĩīˆ ī‰Šī‰‚ī‹ˆīŠ‰īˆ ī‹“īŠŧīŠ§ Faculty of Electrical and Electronic Eng. 69 Automatic Control & Automation Dept.
  • 14. ī‹‘ī‰ĒīŠŦī‰ļīŠī‰īˆ ī‰ī‰‚ī‹€īŠ¸ī‰šī‰ŽīŠī‰īˆ ī‹’īŠ‰ī‰Ēī‰‰ īˆ  īˆ  ī‹’ī‰’īŠģī‰‚ī‰’īŠģī‰īˆ ī‹’ī‰ŽīŠŧīŠ†ī‰ īˆ  īˆ īˆēī‹‘ī‰Ļī‹ī‰ĻīŠ†ī‰īˆ ī‰ī‰‚ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹ŽīŠ‰īˆ•īŠģī‰īˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ īˆ  īˆ  ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‰ ī‰Ēī‰ą īˆ  īˆ īˆŽīˆ¨OC1AīˆŠīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ī‹Œī‰ĩīˆ ī‰Ļī‹ŽīŠģī‹Œī‰ Dtmfout Number , Duration īˆ  īˆ īˆŽī‰Ēī‰˛īŠ§īˆ ī‹’ī‰Žī‰ŽīŠģī‰īˆ īŠąī‰ī‰‚īˆšī‰īˆ ī‰œī‹Žī‰ī‰‚īŠ°īŠŋīˆ ī‹’ī‰™ī‹ŒīŠģīˆ ī‹‚ī‰‚īŠŗī‰Šī‰ƒīˆ ī‰Ļī‰™ī‰ƒ :Number īˆ  īˆ Dtmfout String , Duration īˆ  īˆ īˆŽī‹’ī‹Žī‹ƒī‰‚ī‰‘īˆ ī‹īŠŧī‹ŽīŠī‰‚ī‰‰īˆ ī‹’ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‹…īŠŋī‰Ģīˆ īˆēDuration īˆ  īˆ īˆŽī‹§ī‹ĩī‹īŠŋī‰‚īŠˇīˆ īŠžī‰‚ī‰ļī‰ī‹œī‰īˆ ī‹īŠŗī‰Šīˆ īŠŊīŠ¸ī‰˛ī‰īˆ īˆžīŠģī‰īˆ ī‹‚ī‰‚īŠŗī‰Šī‹žī‰īˆ ī‹’īŠ§ī‹Œī‹€īŠ‰īˆ īˆēString īˆ  īˆ īˆēī‹‘ī‰Šī‰ī‰ĻīŠģī‰īˆ īŠŊī‹ŽīŠŦī‰˛ī‰īˆ ī‰—īŠŋī‰‚ī‹ƒī‰Ēī‰‰ $regfile = "m128def.dat" $crystal = 8000000 īˆ  īˆ īˆŽī‰ī‰‚ī‹ˆī‹Žī‰•ī‹Œī‰ŽīŠģī‰ '------------------- Enable Interrupts īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ DTMFīˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹†ī‹žīˆ ī‰ī‰‚īŠ¨ī‰ŋī‰‚īŠ´īŠī‰īˆ īŠŊī‹ŽīŠ¨īŠ°ī‰ īˆ  īˆ ī‰‚ī‹ˆīŠŧī‹€īŠ§īˆ īŠŸīˆ 1ī‰īŠŗī‹›īŠī‰ '------------------- Dim Var As Byte Dim Btmp As Byte , Sdtmf As String * 10 īˆ  īˆ ī‰‚īˆšīˆ ī‹’ī‹Žī‹–ī‰ī‰Ļī‰Žī‰‰ī‹œī‰īˆ ī‹ī‹ŽīŠ´īŠģī‰īˆ ī‰Ĩī‰‚ī‹„ī‰­ī‰‡ī‹‹īˆ ī‰ī‹œī‹Œī‰šī‰ŽīŠī‰īˆ īŠąī‹ī‰ĒīŠ¨ī‰ Sdtmf = "1234567890" '------------------- Do Dtmfout Sdtmf , 50 Waitms 1000 īˆ ī‰ī‰‚ī‹€īŠŦī‹ƒīˆ ī‰ī‰ī‹Œī‰ĩī‰ƒīˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ ī‰‚ī‹ˆī‹ŽīŠ¯īˆ ī‹ī‰Žī‹īˆ ī‹ī‰Žī‹Žī‹–ī‰ĒīŠģī‰īˆ ī‰—īŠŋī‰‚ī‹ƒīˆ•īŠģī‰īˆ ī‹’īŠ´īŠŧī‰™ For Btmp = 0 To 15 Dtmfout Btmp , 100 īˆ  īˆ īˆŽī‹’īŠ°īŠŧī‰ŽīŠ‹ Waitms 500 īˆ  īˆ  Next Btmp Loop īˆ ī‰‚ī‹ˆī‹ƒī‰ƒīˆ ī‰‚ī‹€īŠˇīˆ ī‹’īŠ¨ī‰ŋī‰‚īŠ´īŠī‰īˆ īŠĒī‰‚īŠ¨ī‰ąīˆ īŠŊī‹ŽīŠ¨īŠ°ī‰īˆ ī‰‹īŠīˆ ī‰ī‰¨īŠģīˆ ī‰ī‰‚ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Ļī‹ŽīŠģī‹Œī‰īˆ īŠŸīˆ 1ī‰īŠŗī‹›īŠī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰Ļī‹€ī‰ŽīŠ¨ī‰īˆ Dtmfoutīˆ ī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰īˆ ī‹†ī‰‡īˆ īˆē1ī‹’īŠ¤ī‰™ī‹īŠŋ īˆ  īˆ īˆŽīŠĄīŠ´īŠ¯īˆ OC1Aīˆ ī‰‹ī‹ąīŠ´īŠģī‰īˆ ī‹“īŠŧīŠ§īˆ ī‰ī‰‚ī‹€īŠŦī‹„īŠģī‰īˆ ī‰Šī‰ī‰Ļī‰ĩī‰ˆī‰‰īˆ ī‹‚ī‹ŒīŠ´ī‰Žī‰­ .4MHZ ~ 8MHZīˆ īŠ”ī‰‰īˆ ī‹†ī‹ŒīŠ¸ī‹īˆ ī‹†ī‰ƒīˆ ī‰‹īŠīˆ īˆ ī‹īŠģī‰‚ī‰Žī‰Žī‹ī‰ĒīŠ¸īŠģī‰īˆ ī‰Ģī‰ī‰Ŧīˆšī‰īˆ ī‰Ĩī‰Ĩī‰Ēī‰īˆ ī‹†ī‰‡īˆ īˆē2ī‹’īŠ¤ī‰™ī‹īŠŋ īˆ ī‹Šī‰¨īˆšīˆ  ī‹’ī‹Žī‰šī‰‚ī‹ī‰ĒīŠģī‰īˆ  ī‰ī‰‚īŠŗī‹īŠ¨īŠģī‰īˆ  ī‹ī‹ˆīŠ°īŠģ Atmel application note (AN314)īˆ  ī‹’ī‹Žī‹„īŠ°īŠģī‰īˆ  ī‹’īŠ´ī‹Žī‰‘ī‹ŒīŠģī‰īˆ  ī‹’īŠ¨ī‰•ī‰ī‰ĒīŠŋīˆ  ī‹•ī‰‚ī‰•ī‰ĒīŠģī‰īˆ  īˆē3ī‹’īŠ¤ī‰™ī‹īŠŋ īˆ  īˆ  īˆŽī‹’ī‹€ī‹ŽīŠŧīŠ¨ī‰ŽīŠģī‰ ī‹’ī‰ŽīŠ—ī‹žī‰ī‹‹īˆ ī‹īŠģī‹ ī‰īˆ ī‹īŠ¸ī‰šī‰ŽīŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„ī‹‡īˆ ī‹ī‰ŽīŠŗ 70 ī‹’ī‹Žī‹ƒī‹‹īˆ–īŠ¸īŠģī‹ĸī‰ī‹‹īˆ ī‹’ī‹Žī‹–ī‰‚ī‰‰ī‰Ēī‹ˆīŠ¸īŠģī‰īˆ ī‹’ī‰­ī‰Ļī‹„īˆšī‰īˆ ī‹’ī‹ŽīŠŧīŠˇ