SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne


      

                     ‫ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ‬

                   

                          




                          




                   Programming
      Embedded Systems Microcontroller

You Can Practice Microcontroller Programming Easily Now!
      WALID BALID, Tuesday, December 15, 2009
                                                                                    

Essential Instructions in Bascom-AVR                        Bascom-AVR

                                                                        ·
                                                             
$regfile = "m128def.dat"                                              ATmega128
$crystal = 1000000                                           
$baud = 9600                                                       


                                                                               ·
                                                             
Wait value                                                          Value
Waitms value                                                    Value
Waitus value                                                 Value


                                      / ·
                                                         
Config Portc = Output                                                                C
Config Portc.5 = Output                                               C5
Config Portc = Input                                                                 C
Config Pinc.5 = Input                                                 C5
Portc = 255                                                                   C
Pinc.5 = 1                                                     C5
Pinc.5 = 0                                                C5
Portc = &B11110000                                                       C
                                              /
Config Portc = &B11110000
                                                             10
Leds Alias Portd                               LedsD
Leds Alias Portd.5                              Led5


     

                                                                               


                         42                            
Practical Class 2                                                               Programming Microcontrollers

                                             Set/Reset ·
                                                        
Set bit                                               /
Reset bit                                              /
Toggle bit                                     /
                                                                                                                 
                                                                               ·
                                                        
If Expression1 Then
   Statements1                                          
   ...
Elseif Expression2 Then                                                                         
   Statements2
                                                                           11
   ...
Else                                                                    22
   Statements3
   ...                                                                             3
End If
SELECT CASE var
                                                        
     Case Test1 : Statements1                                                           
     Case Test2 : Statements2                                         1 var = Test1
     Case Else : Statements3                                          2 var = Test2
                                                                                     3
END SELECT


                                                                                 ·
                                                        
Do
                                                      
     Statements
                                                     
Loop [until Expression]
While Condition

     Statements                                              
Wend
For Var = Start To End [step Value]                    
     Statements                               End  Start
Next Var                                                                                      .step
Exit For                                                                          For
Exit Do                                                                           Do
Exit While                                                                     While

Faculty of Electrical and Electronic Eng.      43                      Automatic Control & Automation Dept.
                                                                     

                                       SRAM ·
                                               
Dim Var1 As Bit                                               0 or 1
Dim Var2 As Byte                                             0 to 255
Dim Var3 As Integer                                  -32,768 to +32,767
Dim Var4 As Word                                           0 to 65535
Dim Var5 As Long                            -2147483648 to 2147483647
Dim Var6 As Single                           1.5 x 10^–45 to 3.4 x 10^38
Dim Var7 As Double                                               
Dim Var8 As String * 1                      *   chr_num

Dim Array(8) As Byte                                                  
Const Symbol = Numconst
Ex. Const Pi = 3.14159265358979
                                                                         
Const Symbol = Stringconst
Ex. Const S = "TEST"                                                    
Const Symbol = Expression
Ex. Const E =(b1 * 3) + 2
                                                                          
Local Var As Type                      


                                                            ·
                                               
                                           Px.y     
Debounce Px.y , state , label , Sub
Ex. Debounce Key1 , 0 , Sw1 , Sub
                                       state
                                            label
                                       Debounce 
Config Debounce = time
                                                            
Bitwait x , Set/reset                           
Ex. Bitwait Pinb.7 , reset              




          44                            
Practical Class 2                                                                     Programming Microcontrollers

      Exp.1: Scrolling LEDs                                                


                                                                                                     
         
                                                                                                     




 
                                                                                                      
                                                                                         JP9, JP10
                                                                                                     
       
                                                                                              .LEDs7         -1
                                                                                         -2
                                                         -3
      Faculty of Electrical and Electronic Eng.                     45                Automatic Control & Automation Dept.
                                                                         

                                                   -4
                                                                                 
$regfile = "m128def.dat"
$crystal = 1000000                                                
'-----------------------
Config Portd.0 = Output
Config Portd.1 = Output
Config Portd.2 = Output
Config Portd.3 = Output
                                                                
Config Porte.4 = Output
Config Porte.5 = Output
Config Porte.6 = Output
Config Porte.7 = Output
'-----------------------
Leds1 Alias Portd                            
Leds2 Alias Porte                                                     
'-----------------------
Dim I As Byte , J As Byte                                      
'-----------------------
Do
   For I = 0 To 3
      J = I + 4                              
      Set Leds1.i
      Set Leds2.j                                                    
      Wait 1
   Next I

   For I = 3 To 0 Step -1
      J = I + 4
      Reset Leds1.i                          
      Reset Leds2.j
      Wait 1                                                   
   Next I
Loop
End
                                                                                                        




            46                             
Practical Class 2                                                            Programming Microcontrollers

      Exp.2: Tact Switches                                                  


                                                                                            
                                     
                                                                                            




 
                                                                                             
                                                                                 JP6, JP8
                                                                                                              
      Faculty of Electrical and Electronic Eng.             47               Automatic Control & Automation Dept.
                                                                                            

                                                                                                      
                                         
                                   GNDJP6, JP8 -1
                                                       VCC JP6, GNDJP8 -2

                                                           GNDJP6, JP8
$regfile = "m128def.dat"
$crystal = 1000000                                                                    
$baud = 4800
'-----------------------
Config Debounce = 150                                             
Config    Pind.0       =   Input
Config    Pind.1       =   Input
Config    Pind.2       =   Input
Config    Pind.3       =   Input
                                                                                   
Config    Pine.4       =   Input
Config    Pine.5       =   Input
Config    Pine.6       =   Input
Config    Pine.7       =   Input

Portd.0 = 1 : Portd.1 = 1
Portd.2 = 1 : Portd.3 = 1
Porte.4 = 1 : Porte.5 = 1
                                                                               
Porte.6 = 1 : Porte.7 = 1
'-----------------------
Key1 Alias Pind.0
Key2 Alias Pind.1
Key3 Alias Pind.2
Key4 Alias Pind.3                                                
Key5 Alias Pine.4
                                                                                       
Key6 Alias Pine.5
Key7 Alias Pine.6
Key8 Alias Pine.7
'-----------------------

Do
     Debounce     Key1     ,   0   ,   Sw1   ,   Sub
     Debounce     Key2     ,   0   ,   Sw2   ,   Sub
     Debounce     Key3     ,   0   ,   Sw3   ,   Sub
     Debounce     Key4     ,   0   ,   Sw4   ,   Sub                            
     Debounce     Key5     ,   0   ,   Sw5   ,   Sub
     Debounce     Key6     ,   0   ,   Sw6   ,   Sub                          
     Debounce     Key7     ,   0   ,   Sw7   ,   Sub
     Debounce     Key8     ,   0   ,   Sw8   ,   Sub

Waitms 200

Loop
End
'-----------------------


                                48                             
Practical Class 2                                                             Programming Microcontrollers

Sw1:                                                                  
   Print "Switch(1)              is pressed!"
Return                                                
'/------------
Sw2:                                                         
   Print "Switch(2)              is pressed!"
Return
'/------------
Sw3:
   Print "Switch(3)              is pressed!"
Return
'/------------
Sw4:
   Print "Switch(4)              is pressed!"
Return
'/------------
Sw5:
   Print "Switch(5)              is pressed!"
Return
'/------------
Sw6:
   Print "Switch(6)              is pressed!"
Return
'/------------
Sw7:
   Print "Switch(7)              is pressed!"
Return
'/------------
Sw8:
   Print "Switch(8)              is pressed!"
Return




Faculty of Electrical and Electronic Eng.       49                     Automatic Control & Automation Dept.
                                                                                  

                                          VCC JP8‫ و‬GNDJP6,
   PortD
                                                         S6




 
                                                                                                                     
      $regfile = "m128def.dat"
      $crystal = 1000000                                                           
      $baud = 4800
      '-----------------------
      Config Debounce = 150                                      
      Config    Pind.0       =   Input
      Config    Pind.1       =   Input
      Config    Pind.2       =   Input
      Config    Pind.3       =   Input
                                                                                
      Config    Pine.4       =   Input
      Config    Pine.5       =   Input
      Config    Pine.6       =   Input
      Config    Pine.7       =   Input


                               50                          
Practical Class 2                                                          Programming Microcontrollers

Portd.0 = 0 : Portd.1 = 0
Portd.2 = 0 : Portd.3 = 0                             Portd
Porte.4 = 1 : Porte.5 = 1
Porte.6 = 1 : Porte.7 = 1                             PortE
'-----------------------
Key1 Alias Pind.0
Key2 Alias Pind.1
Key3 Alias Pind.2
Key4 Alias Pind.3                           
Key5 Alias Pine.4
Key6 Alias Pine.5                                                     
Key7 Alias Pine.6
Key8 Alias Pine.7
'-----------------------
Do
   Debounce Key1 , 0 , Sw1 , Sub
   Debounce Key2 , 0 , Sw2 , Sub
   Debounce Key3 , 0 , Sw3 , Sub
   Debounce Key4 , 0 , Sw4 , Sub
   Debounce Key5 , 0 , Sw5 , Sub                              
   Debounce Key6 , 0 , Sw6 , Sub                             
   Debounce Key7 , 0 , Sw7 , Sub
   Debounce Key8 , 0 , Sw8 , Sub
Waitms 200
Loop
End
'-----------------------
Sw1:
   Print "Switch(1) is pressed!"
Return
'/------------
Sw2:
   Print "Switch(2) is pressed!"
Return
'/------------
Sw3:
   Print "Switch(3) is pressed!"
Return
'/------------
Sw4:
   Print "Switch(4) is pressed!"
Return
'/------------                                                    
Sw5:
   Print "Switch(5) is pressed!"                  
Return                                                   
'/------------
Sw6:
   Print "Switch(6) is pressed!"
Return
'/------------
Sw7:
   Print "Switch(7) is pressed!"
Return
'/------------
Sw8:
   Print "Switch(8) is pressed!"
Return


Faculty of Electrical and Electronic Eng.   51                     Automatic Control & Automation Dept.
                                                                             

      Exp.3: Expansion Connectors                         /


                                                                                            
            /–
                                                                                             




 
                                                                                             
                                  –JP1~ JP6
                                                                                             
  
                 S
                                     VCC           -1
                                 GND             -2


                                                                                                                  
                                                                                                                  
                                                                                                                  


                             52                       
Practical Class 2                                                            Programming Microcontrollers

 :GND  ·
$regfile = "m128def.dat"
$crystal = 1000000                                                      
$baud = 4800
'-----------------------
Config Porte = Input
Config Portb = Input
Config Portd = Input                                                 
Config Portc = Input
Config Porta = Input
'-----------------------
Porta = 255
Portb = 255
Portc = 255                                                  
Portd = 255
Porte = 255
'-----------------------
Pa_value Alias Pina
Pb_value Alias Pinb                                
Pc_value Alias Pinc
Pd_value Alias Pind                                                      
Pe_value Alias Pine
'-----------------------
Do
   Print "PA= " ; Pa_value
      Print "PB= " ; Pb_value
         Print "PC= " ; Pc_value
             Print "PD= " ; Pd_value                              
                Print "PE= " ; Pe_value                  
                   Print "------------"
   Wait 1
Loop
End
'-----------------------                                                                                       




Faculty of Electrical and Electronic Eng.        53                   Automatic Control & Automation Dept.
                                                                             

   :VCC ·
$regfile = "m128def.dat"
$crystal = 1000000                                                        
$baud1 = 4800
'-----------------------
Config Porte = Input
Config Portb = Input
Config Portd = Input                                                   
Config Portc = Input
Config Porta = Input
'-----------------------
Porta = 0
Portb = 0
Portc = 0                                                    
Portd = 0
Porte = 0
'-----------------------
Pa_value Alias Pina
Pb_value Alias Pinb                                     
Pc_value Alias Pinc
Pd_value Alias Pind                                                     
Pe_value Alias Pine
'-----------------------
Open "com2:" For Binary As #1

Do
   Print #1 , "PA= " ; Pa_value
      Print #1 , "PB= " ; Pb_value
         Print #1 , "PC= " ; Pc_value
            Print #1 , "PD= " ; Pd_value                            
               Print #1 , "PE= " ; Pe_value
                  Print #1 , "-----------"
                                                           
   Wait 1
Loop

Close #1
End
'-----------------------




                   54                          
Practical Class 2                                                                    Programming Microcontrollers

      Exp.4: Controlling Relay (On/Of)
                                    f                                   


                                                                                                    
                                                   
                                                                                                    




 
                                                                                                     
                                                                                   JP22~ JP21
                                                                                                                      
      Faculty of Electrical and Electronic Eng.                   55                 Automatic Control & Automation Dept.
                                                                                  

                                                                                           
     Portd.7  Portd.5       
                                                                       K2K1
                                                                                       
$regfile = "m128def.dat"
$crystal = 1000000                                                              
'-----------------------
Config Portd.5 = Output                                                      
Config Portd.7 = Output
'-----------------------
Relay1 Alias Portd.5                                          
Relay2 Alias Portd.7                                                         
'-----------------------
Dim I As Byte                                                                
'-----------------------
   For I = 0 To 9
      Set Relay1
      Wait 2
      Set Relay2

         Wait 2
                                                                          
      Reset Relay1
      Wait 2
      Reset Relay2
   Next I
End
'-----------------------




                        56                          

Contenu connexe

Tendances

3相ACモーターのスパイスモデルの概要
3相ACモーターのスパイスモデルの概要3相ACモーターのスパイスモデルの概要
3相ACモーターのスパイスモデルの概要Tsuyoshi Horigome
 
Cn3210001005
Cn3210001005Cn3210001005
Cn3210001005IJMER
 
Concept Kit:PWM Buck Converter Transients Model
Concept Kit:PWM Buck Converter Transients ModelConcept Kit:PWM Buck Converter Transients Model
Concept Kit:PWM Buck Converter Transients ModelTsuyoshi Horigome
 
DRV401AIDWPG4
DRV401AIDWPG4DRV401AIDWPG4
DRV401AIDWPG4spicepark
 
ICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization EnvironmentICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization EnvironmentNMDG NV
 
A3918 low voltage dc motor driver allegro datasheet[1]
A3918 low voltage dc motor driver allegro   datasheet[1]A3918 low voltage dc motor driver allegro   datasheet[1]
A3918 low voltage dc motor driver allegro datasheet[1]putchi56
 
Electronic circuit design lab manual
Electronic circuit design lab manualElectronic circuit design lab manual
Electronic circuit design lab manualawais ahmad
 
SPICE MODEL of uPC78L10J in SPICE PARK
SPICE MODEL of uPC78L10J in SPICE PARKSPICE MODEL of uPC78L10J in SPICE PARK
SPICE MODEL of uPC78L10J in SPICE PARKTsuyoshi Horigome
 
Programming And Controlling Puma Arms
Programming And Controlling Puma ArmsProgramming And Controlling Puma Arms
Programming And Controlling Puma Arms블로그코디
 
SPICE MODEL of uPC2407A in SPICE PARK
SPICE MODEL of uPC2407A in SPICE PARKSPICE MODEL of uPC2407A in SPICE PARK
SPICE MODEL of uPC2407A in SPICE PARKTsuyoshi Horigome
 

Tendances (20)

3相ACモーターのスパイスモデルの概要
3相ACモーターのスパイスモデルの概要3相ACモーターのスパイスモデルの概要
3相ACモーターのスパイスモデルの概要
 
SPICE Model of TA7291P
SPICE Model of TA7291PSPICE Model of TA7291P
SPICE Model of TA7291P
 
LM555
LM555LM555
LM555
 
Cn3210001005
Cn3210001005Cn3210001005
Cn3210001005
 
Concept Kit:PWM Buck Converter Transients Model
Concept Kit:PWM Buck Converter Transients ModelConcept Kit:PWM Buck Converter Transients Model
Concept Kit:PWM Buck Converter Transients Model
 
DRV401AIDWPG4
DRV401AIDWPG4DRV401AIDWPG4
DRV401AIDWPG4
 
ICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization EnvironmentICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization Environment
 
At24 c512b
At24 c512bAt24 c512b
At24 c512b
 
A3918 low voltage dc motor driver allegro datasheet[1]
A3918 low voltage dc motor driver allegro   datasheet[1]A3918 low voltage dc motor driver allegro   datasheet[1]
A3918 low voltage dc motor driver allegro datasheet[1]
 
Lm741
Lm741Lm741
Lm741
 
Electronic circuit design lab manual
Electronic circuit design lab manualElectronic circuit design lab manual
Electronic circuit design lab manual
 
Objective2
Objective2Objective2
Objective2
 
Objective5
Objective5Objective5
Objective5
 
SPICE MODEL of uPC78L10J in SPICE PARK
SPICE MODEL of uPC78L10J in SPICE PARKSPICE MODEL of uPC78L10J in SPICE PARK
SPICE MODEL of uPC78L10J in SPICE PARK
 
Programming And Controlling Puma Arms
Programming And Controlling Puma ArmsProgramming And Controlling Puma Arms
Programming And Controlling Puma Arms
 
Ec 2-simulation-lab
Ec 2-simulation-labEc 2-simulation-lab
Ec 2-simulation-lab
 
SPICE MODEL of uPC2407A in SPICE PARK
SPICE MODEL of uPC2407A in SPICE PARKSPICE MODEL of uPC2407A in SPICE PARK
SPICE MODEL of uPC2407A in SPICE PARK
 
Objectives
ObjectivesObjectives
Objectives
 
R2 R
R2 RR2 R
R2 R
 
Ec ii lab manual
Ec ii lab manualEc ii lab manual
Ec ii lab manual
 

En vedette

AVR 기초와 응용 강의노트(최한호)
AVR 기초와 응용 강의노트(최한호)AVR 기초와 응용 강의노트(최한호)
AVR 기초와 응용 강의노트(최한호)활 김
 
아두이노와 Fpga를 이용한 로봇제작
아두이노와 Fpga를 이용한 로봇제작아두이노와 Fpga를 이용한 로봇제작
아두이노와 Fpga를 이용한 로봇제작chcbaram
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4AL-AWAIL for Electronic Engineering
 
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 - Lecture3
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3AL-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 - 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
 
Robot After 10 Years
Robot After 10 YearsRobot After 10 Years
Robot After 10 YearsSung uk ham
 
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
 
Character smart paper toy robot
Character smart paper toy robotCharacter smart paper toy robot
Character smart paper toy robotDeok Hyeon Ko
 
Open source Embedded systems
Open source Embedded systemsOpen source Embedded systems
Open source Embedded systemsH K Yoon
 
[드론] 펌웨어 분석 [2015.5.23]
[드론] 펌웨어 분석 [2015.5.23][드론] 펌웨어 분석 [2015.5.23]
[드론] 펌웨어 분석 [2015.5.23]chcbaram
 

En vedette (13)

AVR 기초와 응용 강의노트(최한호)
AVR 기초와 응용 강의노트(최한호)AVR 기초와 응용 강의노트(최한호)
AVR 기초와 응용 강의노트(최한호)
 
아두이노와 Fpga를 이용한 로봇제작
아두이노와 Fpga를 이용한 로봇제작아두이노와 Fpga를 이용한 로봇제작
아두이노와 Fpga를 이용한 로봇제작
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4
 
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 - Lecture3
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture3
 
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 - 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
 
Robot After 10 Years
Robot After 10 YearsRobot After 10 Years
Robot After 10 Years
 
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
 
Character smart paper toy robot
Character smart paper toy robotCharacter smart paper toy robot
Character smart paper toy robot
 
Open source Embedded systems
Open source Embedded systemsOpen source Embedded systems
Open source Embedded systems
 
[드론] 펌웨어 분석 [2015.5.23]
[드론] 펌웨어 분석 [2015.5.23][드론] 펌웨어 분석 [2015.5.23]
[드론] 펌웨어 분석 [2015.5.23]
 

Similaire à Programming Microcontrollers Made Easy

Basic engineering electronics Op Amp.pdf
Basic engineering electronics Op Amp.pdfBasic engineering electronics Op Amp.pdf
Basic engineering electronics Op Amp.pdfhappycocoman
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language samt7
 
รายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมรายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมChetoss Retos
 
รายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมรายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมChetoss Retos
 
รายงานการทำ Lab วันที่ 10 ธันวาคม 2
รายงานการทำ Lab วันที่ 10 ธันวาคม 2รายงานการทำ Lab วันที่ 10 ธันวาคม 2
รายงานการทำ Lab วันที่ 10 ธันวาคม 2Chetoss Retos
 
รายงานการทำ Lab วันที่ 10 ธันวาคม .1
รายงานการทำ Lab วันที่ 10 ธันวาคม .1รายงานการทำ Lab วันที่ 10 ธันวาคม .1
รายงานการทำ Lab วันที่ 10 ธันวาคม .1Chetoss Retos
 

Similaire à Programming Microcontrollers Made Easy (7)

Basic engineering electronics Op Amp.pdf
Basic engineering electronics Op Amp.pdfBasic engineering electronics Op Amp.pdf
Basic engineering electronics Op Amp.pdf
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
 
รายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมรายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคม
 
รายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคมรายงานการทำ Lab วันที่ 10 ธันวาคม
รายงานการทำ Lab วันที่ 10 ธันวาคม
 
รายงานการทำ Lab วันที่ 10 ธันวาคม 2
รายงานการทำ Lab วันที่ 10 ธันวาคม 2รายงานการทำ Lab วันที่ 10 ธันวาคม 2
รายงานการทำ Lab วันที่ 10 ธันวาคม 2
 
รายงานการทำ Lab วันที่ 10 ธันวาคม .1
รายงานการทำ Lab วันที่ 10 ธันวาคม .1รายงานการทำ Lab วันที่ 10 ธันวาคม .1
รายงานการทำ Lab วันที่ 10 ธันวาคม .1
 
Test Requirements for Microprocessor Relays
Test Requirements for Microprocessor RelaysTest Requirements for Microprocessor Relays
Test Requirements for Microprocessor Relays
 

Dernier

CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...Nguyen Thanh Tu Collection
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...HetalPathak10
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsArubSultan
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEMISSRITIMABIOLOGYEXP
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 

Dernier (20)

CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristics
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 

Programming Microcontrollers Made Easy

  • 1.    ‫ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ‬     Programming Embedded Systems Microcontroller You Can Practice Microcontroller Programming Easily Now! WALID BALID, Tuesday, December 15, 2009
  • 2.   Essential Instructions in Bascom-AVR Bascom-AVR   ·     $regfile = "m128def.dat"  ATmega128 $crystal = 1000000   $baud = 9600     ·     Wait value  Value Waitms value  Value Waitus value  Value  / ·     Config Portc = Output  C Config Portc.5 = Output C5 Config Portc = Input  C Config Pinc.5 = Input C5 Portc = 255 C Pinc.5 = 1 C5 Pinc.5 = 0 C5 Portc = &B11110000 C / Config Portc = &B11110000  10 Leds Alias Portd  LedsD Leds Alias Portd.5  Led5          42 
  • 3. Practical Class 2 Programming Microcontrollers  Set/Reset ·     Set bit  / Reset bit  / Toggle bit  /     ·     If Expression1 Then Statements1            ... Elseif Expression2 Then   Statements2  11 ... Else 22 Statements3 ...  3 End If SELECT CASE var            Case Test1 : Statements1   Case Test2 : Statements2  1 var = Test1 Case Else : Statements3  2 var = Test2  3 END SELECT   ·     Do          Statements   Loop [until Expression] While Condition Statements    Wend For Var = Start To End [step Value]           Statements End  Start Next Var  .step Exit For For Exit Do Do Exit While  While Faculty of Electrical and Electronic Eng. 43 Automatic Control & Automation Dept.
  • 4.    SRAM ·     Dim Var1 As Bit  0 or 1 Dim Var2 As Byte 0 to 255 Dim Var3 As Integer -32,768 to +32,767 Dim Var4 As Word 0 to 65535 Dim Var5 As Long -2147483648 to 2147483647 Dim Var6 As Single 1.5 x 10^–45 to 3.4 x 10^38 Dim Var7 As Double  Dim Var8 As String * 1  * chr_num Dim Array(8) As Byte   Const Symbol = Numconst Ex. Const Pi = 3.14159265358979   Const Symbol = Stringconst Ex. Const S = "TEST"   Const Symbol = Expression Ex. Const E =(b1 * 3) + 2   Local Var As Type     ·         Px.y      Debounce Px.y , state , label , Sub Ex. Debounce Key1 , 0 , Sw1 , Sub state  label Debounce  Config Debounce = time    Bitwait x , Set/reset           Ex. Bitwait Pinb.7 , reset    44 
  • 5. Practical Class 2 Programming Microcontrollers Exp.1: Scrolling LEDs              JP9, JP10     .LEDs7 -1  -2  -3 Faculty of Electrical and Electronic Eng. 45 Automatic Control & Automation Dept.
  • 6.     -4   $regfile = "m128def.dat" $crystal = 1000000   '----------------------- Config Portd.0 = Output Config Portd.1 = Output Config Portd.2 = Output Config Portd.3 = Output   Config Porte.4 = Output Config Porte.5 = Output Config Porte.6 = Output Config Porte.7 = Output '----------------------- Leds1 Alias Portd  Leds2 Alias Porte  '----------------------- Dim I As Byte , J As Byte   '----------------------- Do For I = 0 To 3 J = I + 4  Set Leds1.i Set Leds2.j   Wait 1 Next I For I = 3 To 0 Step -1 J = I + 4 Reset Leds1.i  Reset Leds2.j Wait 1   Next I Loop End    46 
  • 7. Practical Class 2 Programming Microcontrollers Exp.2: Tact Switches              JP6, JP8   Faculty of Electrical and Electronic Eng. 47 Automatic Control & Automation Dept.
  • 8.       GNDJP6, JP8 -1 VCC JP6, GNDJP8 -2  GNDJP6, JP8 $regfile = "m128def.dat" $crystal = 1000000   $baud = 4800 '----------------------- Config Debounce = 150   Config Pind.0 = Input Config Pind.1 = Input Config Pind.2 = Input Config Pind.3 = Input   Config Pine.4 = Input Config Pine.5 = Input Config Pine.6 = Input Config Pine.7 = Input Portd.0 = 1 : Portd.1 = 1 Portd.2 = 1 : Portd.3 = 1 Porte.4 = 1 : Porte.5 = 1   Porte.6 = 1 : Porte.7 = 1 '----------------------- Key1 Alias Pind.0 Key2 Alias Pind.1 Key3 Alias Pind.2 Key4 Alias Pind.3  Key5 Alias Pine.4   Key6 Alias Pine.5 Key7 Alias Pine.6 Key8 Alias Pine.7 '----------------------- Do Debounce Key1 , 0 , Sw1 , Sub Debounce Key2 , 0 , Sw2 , Sub Debounce Key3 , 0 , Sw3 , Sub Debounce Key4 , 0 , Sw4 , Sub   Debounce Key5 , 0 , Sw5 , Sub Debounce Key6 , 0 , Sw6 , Sub   Debounce Key7 , 0 , Sw7 , Sub Debounce Key8 , 0 , Sw8 , Sub Waitms 200 Loop End '-----------------------  48 
  • 9. Practical Class 2 Programming Microcontrollers Sw1:   Print "Switch(1) is pressed!" Return   '/------------ Sw2:   Print "Switch(2) is pressed!" Return '/------------ Sw3: Print "Switch(3) is pressed!" Return '/------------ Sw4: Print "Switch(4) is pressed!" Return '/------------ Sw5: Print "Switch(5) is pressed!" Return '/------------ Sw6: Print "Switch(6) is pressed!" Return '/------------ Sw7: Print "Switch(7) is pressed!" Return '/------------ Sw8: Print "Switch(8) is pressed!" Return Faculty of Electrical and Electronic Eng. 49 Automatic Control & Automation Dept.
  • 10.    VCC JP8‫ و‬GNDJP6,  PortD  S6     $regfile = "m128def.dat" $crystal = 1000000   $baud = 4800 '----------------------- Config Debounce = 150   Config Pind.0 = Input Config Pind.1 = Input Config Pind.2 = Input Config Pind.3 = Input   Config Pine.4 = Input Config Pine.5 = Input Config Pine.6 = Input Config Pine.7 = Input  50 
  • 11. Practical Class 2 Programming Microcontrollers Portd.0 = 0 : Portd.1 = 0 Portd.2 = 0 : Portd.3 = 0 Portd Porte.4 = 1 : Porte.5 = 1 Porte.6 = 1 : Porte.7 = 1  PortE '----------------------- Key1 Alias Pind.0 Key2 Alias Pind.1 Key3 Alias Pind.2 Key4 Alias Pind.3  Key5 Alias Pine.4 Key6 Alias Pine.5   Key7 Alias Pine.6 Key8 Alias Pine.7 '----------------------- Do Debounce Key1 , 0 , Sw1 , Sub Debounce Key2 , 0 , Sw2 , Sub Debounce Key3 , 0 , Sw3 , Sub Debounce Key4 , 0 , Sw4 , Sub Debounce Key5 , 0 , Sw5 , Sub   Debounce Key6 , 0 , Sw6 , Sub   Debounce Key7 , 0 , Sw7 , Sub Debounce Key8 , 0 , Sw8 , Sub Waitms 200 Loop End '----------------------- Sw1: Print "Switch(1) is pressed!" Return '/------------ Sw2: Print "Switch(2) is pressed!" Return '/------------ Sw3: Print "Switch(3) is pressed!" Return '/------------ Sw4: Print "Switch(4) is pressed!" Return '/------------   Sw5: Print "Switch(5) is pressed!"   Return   '/------------ Sw6: Print "Switch(6) is pressed!" Return '/------------ Sw7: Print "Switch(7) is pressed!" Return '/------------ Sw8: Print "Switch(8) is pressed!" Return Faculty of Electrical and Electronic Eng. 51 Automatic Control & Automation Dept.
  • 12.   Exp.3: Expansion Connectors  /    /–        –JP1~ JP6     S VCC -1  GND -2        52 
  • 13. Practical Class 2 Programming Microcontrollers  :GND  · $regfile = "m128def.dat" $crystal = 1000000   $baud = 4800 '----------------------- Config Porte = Input Config Portb = Input Config Portd = Input   Config Portc = Input Config Porta = Input '----------------------- Porta = 255 Portb = 255 Portc = 255   Portd = 255 Porte = 255 '----------------------- Pa_value Alias Pina Pb_value Alias Pinb  Pc_value Alias Pinc Pd_value Alias Pind   Pe_value Alias Pine '----------------------- Do Print "PA= " ; Pa_value Print "PB= " ; Pb_value Print "PC= " ; Pc_value Print "PD= " ; Pd_value   Print "PE= " ; Pe_value   Print "------------" Wait 1 Loop End '-----------------------   Faculty of Electrical and Electronic Eng. 53 Automatic Control & Automation Dept.
  • 14.    :VCC · $regfile = "m128def.dat" $crystal = 1000000   $baud1 = 4800 '----------------------- Config Porte = Input Config Portb = Input Config Portd = Input   Config Portc = Input Config Porta = Input '----------------------- Porta = 0 Portb = 0 Portc = 0   Portd = 0 Porte = 0 '----------------------- Pa_value Alias Pina Pb_value Alias Pinb  Pc_value Alias Pinc Pd_value Alias Pind   Pe_value Alias Pine '----------------------- Open "com2:" For Binary As #1 Do Print #1 , "PA= " ; Pa_value Print #1 , "PB= " ; Pb_value Print #1 , "PC= " ; Pc_value Print #1 , "PD= " ; Pd_value   Print #1 , "PE= " ; Pe_value Print #1 , "-----------"   Wait 1 Loop Close #1 End '-----------------------  54 
  • 15. Practical Class 2 Programming Microcontrollers Exp.4: Controlling Relay (On/Of) f              JP22~ JP21   Faculty of Electrical and Electronic Eng. 55 Automatic Control & Automation Dept.
  • 16.          Portd.7  Portd.5         K2K1   $regfile = "m128def.dat" $crystal = 1000000   '----------------------- Config Portd.5 = Output   Config Portd.7 = Output '----------------------- Relay1 Alias Portd.5  Relay2 Alias Portd.7   '----------------------- Dim I As Byte   '----------------------- For I = 0 To 9 Set Relay1 Wait 2 Set Relay2 Wait 2   Reset Relay1 Wait 2 Reset Relay2 Next I End '-----------------------  56 