SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen


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

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

                  

                          




                          




                   Programming
      Embedded Systems Microcontroller

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

      Exp.14: 7-Segment Single Display                     


                                                                                             
                                                                 7-Segment
                                                                                              




 
                                                                                              
                                      
                                                           0 – 9 1
                                                          0 – 99 2
                                                       0 – 9999 3
      
      
                                                                                               
                                             
                              92                       
Practical Class 5                                                                          Programming Microcontrollers




  
                                                                              
   CCCA
                           
  
          A,…..,H




                                                
                                                                                                                            
  B,C1
                                                                                                             




 
                                                                                                                            
  PortC
                                                       PortD
      Faculty of Electrical and Electronic Eng.                         93                 Automatic Control & Automation Dept.
                                                                     




      

                                                               
                                            PortC                  
               :‫-7 اﻟﻘﻄﻊ اﻟﱵ ﱔ ﰲ ﺎ ﲻﻞ‬H 6-G 5-F 4-E 3-D 2-C 1-B 0-A                     

          A.B.C.D.E.F             1    1     0        0   0      0     0       0                      0
              B.C                 1    1     1        1   1      0     0        1                     1
           A.B.D.E.G              1    0     1        0   0      1     0       0                      2
           A.B.C.D.G              1    0     1        1   0      0     0       0                      3
            B.C.F.G               1    0     0        1   1      0     0        1                     4
           A.C.D.F.G              1    0     0        1   0      0     1       0                      5
          A.C.D.E.F.G             1    0     0        0   0      0     1       0                      6
             A.B.C                1    1     1        1   1      0     0       0                      7
         A.B.C.D.E.F.G            1    0     0        0   0      0     0       0                      8
          A.B.C.D.F.G             1    0     0        1   0      0     0       0                      9
                     94                    
Practical Class 5                                                                           Programming Microcontrollers

                                          




 
       &HC0              &HF9      &HA4           &HB0       &H99        &H92        &H82        &HF8        &H80       &H90


  
                             

                      :‫اﻟﻘﻄﻊ اﻟﱵ ﱔ ﰲ ﺎ ﲻﻞ‬                    PortC                        
                                                   7-H 6-G 5-F 4-E 3-D 2-C 1-B 0-A                                

                 A.B.C.D.E.F                        0    0          1        1   1      1         1      1                     0
                     B.C                            0    0          0        0   0      1         1      0                     1
                  A.B.D.E.G                         0    1          0        1   1      0         1      1                     2
                  A.B.C.D.G                         0    1          0        0   1      1         1      1                     3
                   B.C.F.G                          0    1          1        0   0      1         1      0                     4
                  A.C.D.F.G                         0    1          1        0   1      1         0      1                     5
                 A.C.D.E.F.G                        0    1          1        1   1      1         0      1                     6
                    A.B.C                           0    0          0        0   0      1         1      1                     7
                A.B.C.D.E.F.G                       0    1          1        1   1      1         1      1                     8
                 A.B.C.D.F.G                        0    1          1        0   1      1         1      1                     9
                                                                                                                              
                                          




 
       &H3F              &H06     &H5B            &H4F   &H66            &H6D        &H7D        &H07        &H7F       &H6F


      
                                                                     255 DEC&HFF

      Faculty of Electrical and Electronic Eng.                         95                  Automatic Control & Automation Dept.
                                                                                 

                                                                                            
 LUT: Look-Up Table            
                                
                                                            
                                                         
Data var1 , … , varn
                                                                           .0
                                                         label Data LUT
var = Lookup(Index , label)
                                                                                             Index
                                                           Data   LUT   
Var = Lookupstr(Index , Label)
                                                                                   Indexlabel
                                                           value  Index   
Var = Lookdown(value,Label,Entries)                       label Data
                                                                                Entries
                                                                 
Restore Label                                             label Data LUT
                                                                           Read Var
                                                           Data   LUT     
Read Var                                                   Restore    
                                                                                                   Var
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                                                                                                                 
                            96                         
Practical Class 5                                                                Programming Microcontrollers

                                                0-9
                                             SW344 
$regfile = "m128def.dat"
$crystal = 8000000                                                             
'---------------------
                                                                 
Config Porta = Output
Segment Alias Porta                                           &H81
Porta = &H81                                                          
Config Portc.4 = Output                                                             
Ctr1 Alias Portc.4
Reset Ctr1                                                   
'---------------------
Dim I As Byte                                                                
'---------------------
Do
   For I = 0 To 9
      Segment = Lookup(i , Seg)                                       
      Waitms 1000
   Next I
                                                                SegData
Loop                                                           Lookup
End
'---------------------

Seg:                                                                    
Data &H81 , &HF3 , &H49 , &H61 , &H33 ,
&H25 , &H05 , &HF1 , &H01 , &H21




Faculty of Electrical and Electronic Eng.              97                 Automatic Control & Automation Dept.
                                                                          

                                0 – 99
                                    SW344,5 
$regfile = "m128def.dat"
$crystal = 8000000                                                       
'---------------------
Config Porta = Output                                   
Segment Alias Porta
Porta = &H81                                                               
Config Portc.4 = Output                                 &H81
Display1 Alias Portc.4                                          
Config Portc.5 = Output                                 
Display2 Alias Portc.5
                                                                        
Set Display1 : Set Display2                                       
'---------------------
Dim I As Byte , J As Byte                                              
'---------------------

Do
     For I = 0 To 9
        For J = 0 To 9                                          
           Segment = Lookup(i , Seg)
           Reset Display1 : Waitms 20                     SegData
           Set Display1
                                                         Lookup
         Segment = Lookup(j , Seg)                                
         Reset Display2 : Waitms 20
         Set Display2                                      
      Next J
   Next I
                                                                       
Loop

End
'---------------------
Seg:
Data &H81 , &HF3 , &H49 , &H61 , &H33 ,                           
&H25 , &H05 , &HF1 , &H01 , &H21




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

                                      0 – 9999
$regfile = "m128def.dat"
$crystal = 8000000                                                                
'---------------------
Config Porta = Output
Segment Alias Porta                                              
Porta = &H81
                                                                                   
Config Portc =          &B11110000                              &H81
Display1 Alias          Portc.4
Display2 Alias          Portc.5                                          
Display3 Alias          Portc.6                                   
Display4 Alias          Portc.7
                                                                                
Set Display1 : Set Display2
Set Display3 : Set Display4
                                                                           
'---------------------
Dim I As Byte , J As Byte
Dim K As Byte , L As Byte                                                      
'---------------------
Do
   For I = 0 To 9
      For J = 0 To 9
         For K = 0 To 9
            For L = 0 To 9
               Segment = Lookup(i , Seg)
               Reset Display1 : Waitms 7
               Set Display1
                                                                        
                        Segment = Lookup(j , Seg)
                        Reset Display2 : Waitms 7                 SegData
                        Set Display2                              Lookup
                        Segment = Lookup(k , Seg)                          
                        Reset Display3 : Waitms 7
                        Set Display3                                
                                                                                  
                Segment = Lookup(l , Seg)
                Reset Display4 : Waitms 7                                      
                Set Display4
             Next L
         Next K
      Next J
   Next I
Loop

End
'---------------------
Seg:
Data &H81 , &HF3 , &H49 , &H61 , &H33 ,                                   
&H25 , &H05 , &HF1 , &H01 , &H21

                                                                                                                 

                                                                                                                 

Faculty of Electrical and Electronic Eng.                 99                 Automatic Control & Automation Dept.
                                                                           

      Exp.15: Real Time Clock                              

                                                                                           
                                                          
                                                                                            




 
                                                                                             
                                                                                      SW2
                                                                                                                 
                                                                                              
                                     
                                                                              
                                       RTC         
                                       32.786 KHZ       
                                                                                                     TOSC1,2

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

                                                                                             
                            
                                                           
Config Clock = Soft | User                                        |
Config Date = Dmy , Separator = Char                   
Time$ = "hh:mm:ss"                                                  
Date$ = "mm/dd/yy"                                                    
Var = Time$                                                                             
Var = Date$                                                                            


                                                                                         
$regfile = "m128def.dat"
$crystal = 8000000                                                                 Directives
'----------------------
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 =
Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E
= Portc.2 , Rs = Portc.3                                                 Configure the LCD display
Config Lcd = 20 * 4
'----------------------
Config Clock = Soft                                             
Config Date = Dmy , Separator = /
Enable Interrupts                                                    //
                                                                                       
Time$ = "16:59:00"
Date$ = "14/04/08"                                              
----------------------
Do
   Print Time$                                                          
   Print Date$
                                                              
    Lcd Time$ : Locate 2 , 1 : Lcd Date$
                                                                    
   Wait 1                                                                       
   Cls
Loop




Faculty of Electrical and Electronic Eng.              101                   Automatic Control & Automation Dept.
                                                                

      Exp.16: DAC using Ladder R-2R                 

                                                                                
                                       R-2R
                                                                                 




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

                                                                                              
                                                 SW37
                                                        SW2
                                                                                               
 
                                              
      0 or 1         
                      
0-255         8-bit       
                                0-5VDC00000000>>11111111
                                                V OUT = V REF x VAL / 2N
 Digital Input
   0 ~ 255




                                                                                                  Analog Output
                                                                                                     0 ~ 5V



             
                                                                                                                
                   ،8-bit
                                         Vstep = VM / 2N = 5 / 255 = 0.019 Volt

                                                                                        
                                                   Vout = Digval x V step
         1000 0001=129
                                                  129 x 0.019 = 2.451V
 Faculty of Electrical and Electronic Eng.                    103              Automatic Control & Automation Dept.
                                                                 

   
                                                                                      




 
                                                                                                       
  V2V1
  
                                             
                                                                                              
                                               1
                                             
                                     0-to-Vcc      
                                      4.5VVcc - 0.5V
                                       2
                                            
                                           3.9V
                                      
                                                                                   5V6.5V
                                     D7
                                                          0 to 2.5V 

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




                                                                    5.5V ~ 12V




                     
                                                                                        
           
                                                         
                                                             x
Var = Round(x)                                                Round(2.3) = 2 , Round(2.8) = 3
                                                        Round(-2.3)   = -2 , Round(-2.8) = -3
Var = Int(source)              Ex: Int(134.567)=134                          
Var = Frac(source) Ex: Frac(134.567)=567                                   
Var = Fix(x)                   EX: Fix(12.98)=12             x
                                                             Var=-1  x<0x
Var = Sgn(x)
                                                                                     Var=1  x>0


                                                                                      
$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
                                                         
'----------------------
Config Porte = Output                              
Digital Alias Porte
'-----------------------                                              
Dim I As Byte , V_out As Single
Const Vlot_step = 5 / 255                                
'-----------------------
Cls
Do
                                                      
   For I = 0 To 255
      Digital = I                             
      V_out = I * Vlot_step
      Lcd "DAC OUT= " ; V_out                 
      Wait 1 : Cls                           
   Next I
Loop                                                       
End

Faculty of Electrical and Electronic Eng.             105                  Automatic Control & Automation Dept.
                                                                            

      Exp.17: Analog Comparator                                         

                                                                                            
                                      
                                                                                             




 
                                                                                              
                                                                                      SW2
                           JP11, JP12Jumpers
                                                                                               
           


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

 ANI0
High   AIN1
         LowAIN0ANI1
 
                                                                                            
  1/
            
                                                                                                                  
                                                                                           
                            
                                                            
                                                           | Aci=On|off
                                                                                                      
                                                         1     Compare=On|off
                                                                         
                                                      Trigger
Config Aci= On|off ,
Compare= On|off ,                                         (Ain0 > Ain1) :Rising
Trigger = TOGGLE|RISING|FALLING                        Ain0
                                                                                                    Ain1
                                                              (Ain0 < Ain1) :Falling
                                                        Ain0
                                                                                                     Ain1
                                                       (Ain0 > Ain1 and Ain0 < Ain1) :Toggle
Enable Aci                                                                
                                                               
On Aci label
                                                                            label
Start Ac                                                                          
Stop Ac                                                                  
                                                                
Enable Interrupts
                                                                                      
                                                       Assembly
nop
                                                                                       



Faculty of Electrical and Electronic Eng.              107                   Automatic Control & Automation Dept.
                                                                   

                                                                           
$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
                                                      

Config Aci = On , Compare = Off , Trigger =         
Rising
On Aci Isr_aci                                                     
Enable Aci                                          
Start Ac
Enable Interrupts                                                    
'-----------------------                                       
Dim I As Byte
'-----------------------
Cls                                                   
Do
   nop                                                        
Loop                                                                     
End
'-----------------------

Isr_aci:                                                
   Cls
   I = I + 1                                        
   Lcd "change: " ; I                                                 
   Waitms 100
Return
                                           

                                           




                                




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

Weitere ähnliche Inhalte

Andere mochten auch

Control in Electric Vechicle Transportation Systems
Control in Electric Vechicle Transportation SystemsControl in Electric Vechicle Transportation Systems
Control in Electric Vechicle Transportation SystemsKamel Alhomsi
 
Mechatronics Programs
Mechatronics  ProgramsMechatronics  Programs
Mechatronics ProgramsEmad Ezzat
 
Decision support systems (ch4)
Decision support systems (ch4)Decision support systems (ch4)
Decision support systems (ch4)DrSamahAhmed
 
Decision support systems (ch1)
Decision support systems (ch1)Decision support systems (ch1)
Decision support systems (ch1)DrSamahAhmed
 
شرح Protecting stp topology
شرح Protecting stp topologyشرح Protecting stp topology
شرح Protecting stp topologyAli Elsayed Saleh
 
شهادة ال CCNP
شهادة ال CCNPشهادة ال CCNP
شهادة ال CCNPrayan7312
 
Cisco certs guide - iTawy
Cisco certs guide - iTawyCisco certs guide - iTawy
Cisco certs guide - iTawyiTawy Community
 
Nature of Electricity
Nature of Electricity Nature of Electricity
Nature of Electricity Aalwan Aziz
 
GIS: Geographic Information Systems
GIS: Geographic Information SystemsGIS: Geographic Information Systems
GIS: Geographic Information Systemsaalaa gaffar
 
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 - 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 -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 - 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
 

Andere mochten auch (20)

Control in Electric Vechicle Transportation Systems
Control in Electric Vechicle Transportation SystemsControl in Electric Vechicle Transportation Systems
Control in Electric Vechicle Transportation Systems
 
Mechatronics Programs
Mechatronics  ProgramsMechatronics  Programs
Mechatronics Programs
 
Decision support systems (ch4)
Decision support systems (ch4)Decision support systems (ch4)
Decision support systems (ch4)
 
Decision support systems (ch1)
Decision support systems (ch1)Decision support systems (ch1)
Decision support systems (ch1)
 
شرح Protecting stp topology
شرح Protecting stp topologyشرح Protecting stp topology
شرح Protecting stp topology
 
Ccnp m
Ccnp mCcnp m
Ccnp m
 
شهادة ال CCNP
شهادة ال CCNPشهادة ال CCNP
شهادة ال CCNP
 
1
11
1
 
Aaa security
Aaa securityAaa security
Aaa security
 
Cisco certs guide - iTawy
Cisco certs guide - iTawyCisco certs guide - iTawy
Cisco certs guide - iTawy
 
Nature of Electricity
Nature of Electricity Nature of Electricity
Nature of Electricity
 
جودة القدرة Power quality
جودة القدرة Power qualityجودة القدرة Power quality
جودة القدرة Power quality
 
GIS: Geographic Information Systems
GIS: Geographic Information SystemsGIS: Geographic Information Systems
GIS: Geographic Information Systems
 
AVR PPT
AVR PPTAVR PPT
AVR PPT
 
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 - 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 -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 - 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
 

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

Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronicsIIT, KANPUR INDIA
 
Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronicsKamil Hussain
 
343logic-design-lab-manual-10 esl38-3rd-sem-2011
343logic-design-lab-manual-10 esl38-3rd-sem-2011343logic-design-lab-manual-10 esl38-3rd-sem-2011
343logic-design-lab-manual-10 esl38-3rd-sem-2011e11ie
 
Executable Specifications in Action
Executable Specifications in ActionExecutable Specifications in Action
Executable Specifications in ActionVagif Abilov
 
Executable Specifications in Action
Executable Specifications in ActionExecutable Specifications in Action
Executable Specifications in ActionVagif Abilov
 
Senior Project Presentation
Senior Project PresentationSenior Project Presentation
Senior Project PresentationTim Heath
 
Assessment questions probability
Assessment questions  probabilityAssessment questions  probability
Assessment questions probabilityErik Tjersland
 
Pma individual assignment ii
Pma  individual assignment iiPma  individual assignment ii
Pma individual assignment iichandraswami
 
86254 162058-ee2255-digital-logic-circuits
86254 162058-ee2255-digital-logic-circuits86254 162058-ee2255-digital-logic-circuits
86254 162058-ee2255-digital-logic-circuitsLekashri Subramanian
 

Ähnlich wie Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5 (11)

Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronics
 
Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronics
 
343logic-design-lab-manual-10 esl38-3rd-sem-2011
343logic-design-lab-manual-10 esl38-3rd-sem-2011343logic-design-lab-manual-10 esl38-3rd-sem-2011
343logic-design-lab-manual-10 esl38-3rd-sem-2011
 
Executable Specifications in Action
Executable Specifications in ActionExecutable Specifications in Action
Executable Specifications in Action
 
Executable Specifications in Action
Executable Specifications in ActionExecutable Specifications in Action
Executable Specifications in Action
 
Senior Project Presentation
Senior Project PresentationSenior Project Presentation
Senior Project Presentation
 
Assessment questions probability
Assessment questions  probabilityAssessment questions  probability
Assessment questions probability
 
00857a
00857a00857a
00857a
 
Pma individual assignment ii
Pma  individual assignment iiPma  individual assignment ii
Pma individual assignment ii
 
86254 162058-ee2255-digital-logic-circuits
86254 162058-ee2255-digital-logic-circuits86254 162058-ee2255-digital-logic-circuits
86254 162058-ee2255-digital-logic-circuits
 
Bca i sem de lab
Bca i sem  de labBca i sem  de lab
Bca i sem de lab
 

Kürzlich hochgeladen

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxKatherine Villaluna
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 

Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5

  • 1.    ‫ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ‬     Programming Embedded Systems Microcontroller You Can Practice Microcontroller Programming Easily Now! WALID BALID, Tuesday, December 15, 2009
  • 2.     Exp.14: 7-Segment Single Display       7-Segment         0 – 9 1 0 – 99 2 0 – 9999 3        92 
  • 3. Practical Class 5 Programming Microcontrollers     CCCA     A,…..,H      B,C1       PortC  PortD Faculty of Electrical and Electronic Eng. 93 Automatic Control & Automation Dept.
  • 4.          PortC    :‫-7 اﻟﻘﻄﻊ اﻟﱵ ﱔ ﰲ ﺎ ﲻﻞ‬H 6-G 5-F 4-E 3-D 2-C 1-B 0-A    A.B.C.D.E.F 1 1 0 0 0 0 0 0 0 B.C 1 1 1 1 1 0 0 1 1 A.B.D.E.G 1 0 1 0 0 1 0 0 2 A.B.C.D.G 1 0 1 1 0 0 0 0 3 B.C.F.G 1 0 0 1 1 0 0 1 4 A.C.D.F.G 1 0 0 1 0 0 1 0 5 A.C.D.E.F.G 1 0 0 0 0 0 1 0 6 A.B.C 1 1 1 1 1 0 0 0 7 A.B.C.D.E.F.G 1 0 0 0 0 0 0 0 8 A.B.C.D.F.G 1 0 0 1 0 0 0 0 9  94 
  • 5. Practical Class 5 Programming Microcontrollers     &HC0 &HF9 &HA4 &HB0 &H99 &H92 &H82 &HF8 &H80 &H90      :‫اﻟﻘﻄﻊ اﻟﱵ ﱔ ﰲ ﺎ ﲻﻞ‬ PortC  7-H 6-G 5-F 4-E 3-D 2-C 1-B 0-A    A.B.C.D.E.F 0 0 1 1 1 1 1 1 0 B.C 0 0 0 0 0 1 1 0 1 A.B.D.E.G 0 1 0 1 1 0 1 1 2 A.B.C.D.G 0 1 0 0 1 1 1 1 3 B.C.F.G 0 1 1 0 0 1 1 0 4 A.C.D.F.G 0 1 1 0 1 1 0 1 5 A.C.D.E.F.G 0 1 1 1 1 1 0 1 6 A.B.C 0 0 0 0 0 1 1 1 7 A.B.C.D.E.F.G 0 1 1 1 1 1 1 1 8 A.B.C.D.F.G 0 1 1 0 1 1 1 1 9       &H3F &H06 &H5B &H4F &H66 &H6D &H7D &H07 &H7F &H6F   255 DEC&HFF Faculty of Electrical and Electronic Eng. 95 Automatic Control & Automation Dept.
  • 6.        LUT: Look-Up Table                      Data var1 , … , varn  .0 label Data LUT var = Lookup(Index , label)  Index   Data   LUT    Var = Lookupstr(Index , Label)  Indexlabel   value  Index    Var = Lookdown(value,Label,Entries)  label Data  Entries           Restore Label  label Data LUT Read Var   Data   LUT      Read Var   Restore      Var                          96 
  • 7. Practical Class 5 Programming Microcontrollers  0-9  SW344  $regfile = "m128def.dat" $crystal = 8000000   '---------------------   Config Porta = Output Segment Alias Porta &H81 Porta = &H81   Config Portc.4 = Output   Ctr1 Alias Portc.4 Reset Ctr1   '--------------------- Dim I As Byte   '--------------------- Do For I = 0 To 9 Segment = Lookup(i , Seg)   Waitms 1000 Next I SegData Loop  Lookup End '--------------------- Seg:   Data &H81 , &HF3 , &H49 , &H61 , &H33 , &H25 , &H05 , &HF1 , &H01 , &H21 Faculty of Electrical and Electronic Eng. 97 Automatic Control & Automation Dept.
  • 8.      0 – 99  SW344,5  $regfile = "m128def.dat" $crystal = 8000000   '--------------------- Config Porta = Output  Segment Alias Porta Porta = &H81   Config Portc.4 = Output &H81 Display1 Alias Portc.4   Config Portc.5 = Output  Display2 Alias Portc.5   Set Display1 : Set Display2   '--------------------- Dim I As Byte , J As Byte   '--------------------- Do For I = 0 To 9 For J = 0 To 9   Segment = Lookup(i , Seg) Reset Display1 : Waitms 20 SegData Set Display1  Lookup Segment = Lookup(j , Seg)   Reset Display2 : Waitms 20 Set Display2   Next J Next I   Loop End '--------------------- Seg: Data &H81 , &HF3 , &H49 , &H61 , &H33 ,   &H25 , &H05 , &HF1 , &H01 , &H21  98 
  • 9. Practical Class 5 Programming Microcontrollers  0 – 9999 $regfile = "m128def.dat" $crystal = 8000000   '--------------------- Config Porta = Output Segment Alias Porta  Porta = &H81   Config Portc = &B11110000 &H81 Display1 Alias Portc.4 Display2 Alias Portc.5   Display3 Alias Portc.6  Display4 Alias Portc.7   Set Display1 : Set Display2 Set Display3 : Set Display4   '--------------------- Dim I As Byte , J As Byte Dim K As Byte , L As Byte   '--------------------- Do For I = 0 To 9 For J = 0 To 9 For K = 0 To 9 For L = 0 To 9 Segment = Lookup(i , Seg) Reset Display1 : Waitms 7 Set Display1   Segment = Lookup(j , Seg) Reset Display2 : Waitms 7 SegData Set Display2  Lookup Segment = Lookup(k , Seg)   Reset Display3 : Waitms 7 Set Display3     Segment = Lookup(l , Seg) Reset Display4 : Waitms 7   Set Display4 Next L Next K Next J Next I Loop End '--------------------- Seg: Data &H81 , &HF3 , &H49 , &H61 , &H33 ,   &H25 , &H05 , &HF1 , &H01 , &H21   Faculty of Electrical and Electronic Eng. 99 Automatic Control & Automation Dept.
  • 10.     Exp.15: Real Time Clock              SW2          RTC            32.786 KHZ         TOSC1,2  100 
  • 11. Practical Class 5 Programming Microcontrollers           Config Clock = Soft | User  | Config Date = Dmy , Separator = Char   Time$ = "hh:mm:ss"   Date$ = "mm/dd/yy"   Var = Time$   Var = Date$     $regfile = "m128def.dat" $crystal = 8000000 Directives '---------------------- Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.3  Configure the LCD display Config Lcd = 20 * 4 '---------------------- Config Clock = Soft   Config Date = Dmy , Separator = / Enable Interrupts  //   Time$ = "16:59:00" Date$ = "14/04/08"   ---------------------- Do Print Time$   Print Date$   Lcd Time$ : Locate 2 , 1 : Lcd Date$  Wait 1   Cls Loop Faculty of Electrical and Electronic Eng. 101 Automatic Control & Automation Dept.
  • 12.     Exp.16: DAC using Ladder R-2R      R-2R      102 
  • 13. Practical Class 5 Programming Microcontrollers    SW37 SW2             0 or 1            0-255         8-bit         0-5VDC00000000>>11111111 V OUT = V REF x VAL / 2N Digital Input 0 ~ 255 Analog Output 0 ~ 5V      ،8-bit Vstep = VM / 2N = 5 / 255 = 0.019 Volt    Vout = Digval x V step   1000 0001=129 129 x 0.019 = 2.451V Faculty of Electrical and Electronic Eng. 103 Automatic Control & Automation Dept.
  • 14.             V2V1                       1          0-to-Vcc        4.5VVcc - 0.5V   2         3.9V    5V6.5V D7   0 to 2.5V   104 
  • 15. Practical Class 5 Programming Microcontrollers 5.5V ~ 12V              x Var = Round(x) Round(2.3) = 2 , Round(2.8) = 3  Round(-2.3) = -2 , Round(-2.8) = -3 Var = Int(source) Ex: Int(134.567)=134   Var = Frac(source) Ex: Frac(134.567)=567   Var = Fix(x) EX: Fix(12.98)=12  x Var=-1  x<0x Var = Sgn(x) Var=1  x>0   $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   '---------------------- Config Porte = Output   Digital Alias Porte '-----------------------   Dim I As Byte , V_out As Single Const Vlot_step = 5 / 255   '----------------------- Cls Do   For I = 0 To 255 Digital = I  V_out = I * Vlot_step Lcd "DAC OUT= " ; V_out   Wait 1 : Cls  Next I Loop   End Faculty of Electrical and Electronic Eng. 105 Automatic Control & Automation Dept.
  • 16.     Exp.17: Analog Comparator              SW2  JP11, JP12Jumpers      106 
  • 17. Practical Class 5 Programming Microcontrollers  ANI0 High   AIN1  LowAIN0ANI1       1/                   | Aci=On|off     1     Compare=On|off    Trigger Config Aci= On|off , Compare= On|off ,    (Ain0 > Ain1) :Rising Trigger = TOGGLE|RISING|FALLING Ain0 Ain1  (Ain0 < Ain1) :Falling Ain0 Ain1  (Ain0 > Ain1 and Ain0 < Ain1) :Toggle Enable Aci            On Aci label  label Start Ac   Stop Ac             Enable Interrupts   Assembly nop   Faculty of Electrical and Electronic Eng. 107 Automatic Control & Automation Dept.
  • 18.       $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   Config Aci = On , Compare = Off , Trigger =  Rising On Aci Isr_aci   Enable Aci  Start Ac Enable Interrupts   '-----------------------   Dim I As Byte '----------------------- Cls  Do nop   Loop   End '----------------------- Isr_aci:   Cls I = I + 1  Lcd "change: " ; I   Waitms 100 Return        108 