Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

‫א‬ ‫א‬

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

‫א א‬ ‫א‬

Programming
Embedded Systems Microcontroller

You Can Practice Microcontroller Programming Easily Now!


Thursday, October 23, 2008

 
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

Exxp.10: Shift & Rotate Instruction


I ns  ‫א‬
‫א‬‫א‬‫א‬W‫ א‬
‫א‬

 W‫א‬‫א‬
 KERottateF ‫א‬‫א‬EShiftF 
‫א‬‫א‬‫א‬
 W‫א‬
 

 
 W‫א‬‫א‬

 ‫א‬F،EShifft RightF‫א‬ S6 ‫א‬
‫א‬  

‫א‬S7‫א‬E
  KEShift LeftftF ‫א‬

‫א‬‫אא‬ S14‫א‬ ERotaate RightF ‫א‬ ‫א‬ S13 ‫א‬
 KERotate RigghtF
 W
‫ א‬

 .Jumpper ‫א‬ JP9 JPP6‫א‬ 

 

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

 W‫א‬‫א‬
 ‫א‬‫א‬  ‫א‬
 ‫א‬  ‫א‬     ‫א‬
Shift var , Right/Left [, shift]
 [, shift]‫א‬‫א‬
 ‫א‬  ‫א‬     
Rotate var , Right/Left [, rotate]
 [, shift]‫א‬‫א‬
 W‫א‬‫א‬
$regfile = "m128def.dat"
$crystal = 8000000  K‫א‬
'---------------------
Config Pine.4 = Input
Config Pine.5 = Input
Config Pine.6 = Input
Config Pine.7 = Input

Pine.4 = 1 : Pine.5 = 1
Pine.6 = 1 : Pine.7 = 1

Shift_r Alias Pine.4 ‫א‬‫א‬‫א‬‫א‬‫א‬


Shift_l Alias Pine.5
Rotat_r Alias Pine.6  K‫א‬
Rotat_l Alias Pine.7

Config Portd = Output


Leds Alias Portd
Portd = &B00000001
'---------------------
Do
Debounce Shift_r , 0 , Sr , Sub
Debounce Shift_l , 0 , Sl , Sub
Debounce Rotat_r , 0 , Rr , Sub
Debounce Rotat_l , 0 , Rl , Sub
Loop
End K‫א‬‫א‬‫א‬
'---------------------
Sr:
If Leds > 1 Then Shift Leds , Right , 1
Return
'---------------------
Sl:
If Leds < 128 Then Shift Leds , Left , 1
Return
'---------------------
Rr:
Rotate Leds , Right , 1  K‫א‬‫א‬‫א‬
Return
'---------------------
Rl:
Rotate Leds , Left , 1
Return
'---------------------

  Faculty of Electrical and Electronic Eng.
 
 3   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

Exxp.11: Get RC
R Value  
 ‫א‬W‫ א‬
‫א‬

 W‫א‬‫א‬
 K 
‫א‬ ‫א‬ 
‫א‬‫א‬
 ‫א‬
 W‫א‬
 

 
 
 W‫א‬‫א‬

‫א‬   ‫א‬ ‫א‬
 ‫א‬    
       

 KGetrc
G 
‫א‬‫א‬

‫א‬‫א‬‫א‬
 
 W
‫א‬

 K
‫א‬SW22‫א‬ .Jumper ‫א‬ JP114‫א‬
 

 
 

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

 W‫א‬‫א‬
 ‫א‬‫א‬  ‫א‬
‫א‬‫א‬
     pinx ‫א‬‫א‬  y
 var = Getrc(pinx , y)
‫א‬‫א‬
 > ‫א‬‫א‬
 
 W‫א‬‫א‬
$regfile = "m128def.dat"
$crystal = 8000000  K‫א‬
'----------------------
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  K‫א‬
'----------------------
Dim Rc_var As Word
'----------------------  ‫א‬
Cls : Cursor Off
Lcd "RC Val= "
Do
Rc_var = Getrc(ping , 2)
Locate 1 , 9
Lcd Rc_var  K‫א‬‫א‬
Waitms 1000
Locate 1 , 8 : Lcd Spc(7)  
Loop

End

 

  Faculty of Electrical and Electronic Eng.
 
 5   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

Exxp.12: IR reeceiver, RCC5-code RC5 ‫א‬IR


I ‫א‬‫א‬W‫ א‬
‫א‬

 W‫א‬‫א‬
  ded 
.RC5, RC5-Extend
R ‫א‬ ECLRM-20038SF ‫א‬
‫א‬
 


 W‫א‬
 

 
 W‫א‬‫א‬

 ‫א‬ ‫א‬‫א‬   
‫א‬    ‫א‬ ‫א‬ ‫א‬  
  

.RC5
‫א‬
 W
‫ א‬

‫א‬SW22‫א‬ .Jumper ‫א‬ JP118‫א‬
 K  

 W‫א‬‫א‬

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

 ‫א‬‫א‬  ‫א‬
 Config Rc5 = Pinb.7   IR‫א‬‫א‬
Getrc5(address , Command)  ‫א‬‫א‬‫א‬‫א‬‫א‬
 W‫א‬‫א‬
$regfile = "m128def.dat"
$crystal = 8000000  K‫א‬
'---------------------
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  K‫א‬
'---------------------
Config Rc5 = Pinb.7
'---------------------  ‫א‬‫א‬‫א‬
Dim Address As Byte , Command As Byte  ‫א‬
Enable Interrupts
'---------------------  ‫א‬‫א‬
Cls
Do
Gosub Remote_control
Loop ‫א‬‫א‬‫א‬‫א‬
'--------------------- ‫א‬‫א‬‫א‬‫א‬‫א‬
Remote_control:
Getrc5(address , Command)
If Address = 0 Then
Command = Command And &B01111111  W‫א‬
Cls  TV‫א‬‫א‬‫א‬‫א‬
Lcd "Command is: " ; Command
Waitms 50 ‫א‬
End If
Return  K‫א‬‫א‬‫א‬‫א‬
'---------------------

 

  Faculty of Electrical and Electronic Eng.
 
 7   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

Exxp.13: IR trransmitter, RC5-code C5‫א‬IR ‫א‬W‫ א‬


 RC ‫א‬

 W‫א‬‫א‬
KRC5 ‫א‬‫א‬
‫א‬
‫א‬ 

 W‫א‬
 

 
 W‫א‬‫א‬

RCC5, 
‫א‬    
‫א‬ ‫א‬ ‫א‬
‫א‬  
  
   

 K
  ‫א‬
KRC5-Extended
 W
‫ א‬

  K
‫א‬SW22‫א‬ .Jumper ‫א‬ JP117‫א‬
 

 W‫א‬‫א‬
 W
 ‫א‬
 ‫א‬‫א‬  ‫א‬
‫א‬  ‫א‬ ‫א‬‫א‬ ‫א‬   
Rcc5send T
Togbit , Address
s , Command
  RCC5‫א‬OCC1A

‫א‬‫א‬
‫א‬ 8   
‫א‬‫א‬‫א‬
 
  Practical Class 4   Programming Microcontrollers
 

 W‫א‬‫א‬
$regfile = "m128def.dat"
$crystal = 8000000  K‫א‬
'---------------------
Config Debounce = 200

Config Pine.4 = Input  K‫א‬‫א‬‫א‬


Porte.4 = 1
'---------------------
Dim Togbit As Byte , Command As Byte ,
Address As Byte

Command = 12  ‫א‬
Togbit = 0
Address = 0  ‫א‬
'---------------------
Do
Debounce Pine.4 , 0 , Pwr_cmd , Sub
Loop
‫א‬‫א‬‫א‬
End  K‫א‬ OC1A pin ‫א‬
'---------------------
 
Pwr_cmd:
Rc5send Togbit , Address , Command
Waitms 200
Return ‫א‬‫א‬‫א‬‫א‬‫א‬
'\-------------\ 
 K‫א‬‫א‬

 
 

  Faculty of Electrical and Electronic Eng.
 
 9   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

Apppendix: Exxp.12 and Exp.13


E W
‫א‬‫א‬


RC5--code‫א‬‫א‬‫א‬ ‫א‬
Detailed Article
A aboutt Remote Control
C and IR Module

W is infraared?
What  ‫؟‬‫א‬‫א‬
‫א‬

‫א‬‫א‬
K‫א‬‫א‬
‫א‬

 
   950nm
‫א‬‫א‬
 9 
‫א‬‫א‬
‫א‬
‫א‬
 K‫א‬‫א‬
‫ א‬

‫א‬‫א‬


 
،
     
  
 
 ‫א‬ 
  ‫א‬‫א‬ 
 ‫א‬ 


K‫א‬‫א‬
‫א‬
‫א‬‫א‬‫א‬‫א‬

    ‫א‬  
  ،
، ‫א‬
 
‫א‬      ،
 ‫א‬ ‫א‬   
    
 
 ‫א‬   ‫א‬  
K‫א‬‫א‬،‫א‬
‫א‬
‫א‬
W
 ‫א‬‫א‬‫א‬
،‫א‬
‫א‬‫א‬
‫א‬

‫א‬ ‫א‬  
‫א‬  ‫א‬  
 ‫א‬
‫א‬  
  ،
‫א‬ ‫א‬ ،‫א‬‫א‬ ،
‫א‬
‫א‬‫א‬
‫א‬ ‫א‬
‫א‬
‫א‬ ‫א‬
‫א‬
‫א‬
 KEAddress
A F ‫א‬‫ א‬

‫א‬،‫א‬
36KHZ‫אא‬‫א‬
 30KHZ
Z – 60KHZ ‫א‬ ‫א‬‫א‬
‫א‬
‫א‬

36KHZ, 38KH
HZ
‫א‬‫א‬‫א‬
‫א‬
KE338KHZF‫א‬
‫א‬
  36~388
‫א‬‫א‬
‫א‬
‫א‬
‫א‬
‫א‬

 K
،‫א‬‫א‬‫א‬
  ‫א‬  ،   366KHZ, 38KH
‫אא‬‫א‬  ‫א‬  HZ    


‫א‬‫א‬،
‫א‬
‫א‬‫א‬ 
‫א‬‫א‬‫א‬
‫א‬
‫א‬‫א‬


 ‫א‬‫א‬ ‫א‬ 
  
   ‫א‬ ‫א‬‫א‬ 
 ‫א‬ 
  
‫א‬


‫א‬‫א‬
‫א‬ 10   
‫א‬‫א‬‫א‬
 
  Pra
actical Class 4
 4   Prrogramming M
Microcontrolllers
 


‫א‬  K
‫א‬ ‫א‬ 
‫א‬    ‫א‬ ، ‫א‬ 
 ‫א‬ ‫א‬‫א‬
 
‫א‬
  277uS  
 
  ،36KHZ
3   
  
  ‫א‬  ‫א‬
 K2
‫א‬
‫א‬‫א‬‫א‬K1
‫א‬‫א‬
‫א‬

   
 1
‫א‬  2 
‫א‬
‫א‬‫א‬‫א‬
 K‫א‬ ‫א‬‫א‬‫א‬


W is IR Transmittin
What T ng protocolss? ‫؟‬‫א‬‫א‬‫א‬‫א‬

‫א‬
،RC5
R  ،SIRCCS ،NEC W
 ،‫א‬   ‫ א‬EF ‫א‬   ‫א‬ 

 ‫א‬  
    
 ‫א‬   KSonyy ،SAMSU
UNG ،JAPAAN
 KEWaveform
msF

RCC5 Transm
mitting protoocols? RC55‫א‬
14   
     ‫א‬ RC5
 R  
   
 ‫א‬ 
1.728m
‫א‬‫א‬، mS
‫א‬‫א‬
‫א‬

 K  ‫א‬1300mS
‫א‬ ‫א‬
 W‫א‬
‫א‬‫א‬‫א‬
‫א‬
‫א‬‫א‬
KEAdddress LengthhF‫א‬‫א‬ -
KECommand
C L
Length ‫א‬ -
F 
KECarrieer Frequenccy F‫א‬ -
KEStart BiitF ‫א‬‫א‬ -
KEHigh-BBit-TimeF"1" ‫א‬ ‫א‬ -

KELow-BBit-TimeF"0" ‫א‬ ‫א‬ -

K‫א‬
‫א‬
‫א‬‫א‬
،، W
 ‫א‬
‫א‬


‫א‬،
‫א‬‫א‬ ‫א‬‫אא‬‫א‬ K ‫א‬
 

  Facculty of Electrrical and Electtronic Eng.
 
  11   Automatiic Control & A
Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 


‫א‬‫א‬‫א‬،


‫א‬‫א‬،
‫א‬
‫א‬‫א‬
 K ‫א‬
‫א‬
،


 ‫א‬‫א‬‫א‬
‫א‬
‫א‬
‫א‬
،‫א‬‫א‬
‫א‬‫א‬

،


‫א‬‫א‬‫א‬
‫א‬،‫אא‬ 
‫א‬
‫א‬‫א‬
‫א‬،
‫א‬
 K

‫א‬
‫א‬،

‫א‬‫א‬ 277µs
‫א‬
‫א‬
‫א‬‫א‬
‫א‬،‫א‬
‫א‬‫א‬‫א‬
‫א‬ EdemodulattorF‫א‬‫א‬
‫א‬
64،‫א‬
32
3 

‫א‬‫א‬
32‫א‬ ‫א‬  "0" K
 
K32 x 27µs of silence 
 27µss

 322 322 x 27µs of silence ،‫א‬‫א‬
 "1"
 K27µs

 
| +---| |---+ |
| | | | | |
| | | | | |
|---+ | | +---|
<-----> <----->
1.7778ms 1.7778ms
Logic 1 Logic 0
 

 
 RC
C5‫א‬
‫א‬

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

 W‫א‬‫א‬14BitsRC5
Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Bit11 Bit12 Bit13 Bit14
start bits control  Address Command
‫א‬EStart Bits or AGC "Automatic Gain Control?F‫א‬‫א‬ WBits1-2 -
K‫א‬‫א‬‫א‬K"1"‫א‬
‫א‬‫א‬‫א‬،EControl Bit or Toggle BitF CHECK bit‫א‬WBit3 -
‫א‬‫א‬‫א‬K‫א‬‫א‬‫א‬‫א‬
،‫א‬‫א‬‫א‬ –‫א‬‫א‬‫א‬
‫א‬‫א‬11‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬
K‫א‬‫א‬
‫א‬‫א‬‫א‬‫א‬،‫א‬‫א‬WBits4-8 -
  W‫א‬‫א‬E2^5=32F32،‫א‬
SYSTEM ADDRESS  EQUIPMENT 
0  TV SET 1 
1  TV SET 2 
2  VIDEOTEXT 
3  EXPANSION FOR TV 1 AND 2 
4  LASER VIDEO PLAYER 
5  VIDEO RECORDER 1 (VCR 1) 
6  VIDEO RECORDER 2 (VCR 2) 
7  RESERVED 
8  SAT 1 
9  EXPANSION FOR VCR 1 OR 2 
10  SAT 2 
11  RESERVED 
12  CD VIDEO 
13  RESERVED 
14  CD PHOTO 
15  RESERVED 
16  AUDIO PREAMPLIFIER 1 
17  RECEIVER / TUNER 
18  TAPE / CASSETE RECORDER  
19  AUDIO PREAMPLIFIER 2 
20  CD 
21  AUDIO RACK 
22  AUDIO SAT RECEIVER 
23  DCC RECORDER 
24  RESERVED 
25  RESERVED 
26  WRITABLE CD 
26‐31  RESERVED 

  Faculty of Electrical and Electronic Eng.
 
  13   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

‫א‬‫א‬،‫א‬‫א‬‫א‬  WBits9--14 -


‫א‬‫א‬‫א‬ 
 E2^6=644F  
  64‫אא‬‫א‬ ،‫א‬‫א‬ 

W‫א‬‫א‬‫א‬


COMMAND (in decimal)  DESSCRIPTION of FFUNCTION 
0‐9  NUMERIC KEYS 0 ‐
K 9
12  STANDBY
13  MUTE
14  PRESETS
16  VOLUME UP P
17  VOLUME DO OWN
18  BRIGHTNES SS +
19  BRIGHTNES SS ‐
20  COLOR SATTURATION +
21  COLOR SATTURATION ‐
22  BASS UP
23  BASS DOWN N
24  TREBLE +
25  TREBLE ‐
26  BALANCE RRIGHT
27  BALANCE LLEFT
48  PAUSE
50  FAST REVERSE
52  FAST FORWWARD‐
53  PLAY
54  STOP
55  RECORD
63  SYSTEM SELECT
71  DIM LOCALL DISPLAY
77  LINEAR FUN NCTION (+)
78  LINEAR FUN NCTION (‐)
80  STEP UP
81  STEP DOWN N
82  MENU ON
83  MENU OFF
84  DISPLAY A//V SYS STATUSS
85  STEP LEFT
86  STEP RIGHT T
87  ACKNOWLE EDGE
88  PIP ON/OFF F
89  PIP SHIFT 
90  PIP MAIN SWWAP
91  STROBE ONN/OFF
92  MULTI STROBE
93  MAIN FROZ ZEN
94  3/9 MULTI SCAN
95  PIP SELECT
T
96  MOSAIC MU ULTI PIP
97  PICTURE DN NR
98  MAIN STORRED
99  PIP STROBE E
100
0  RECALL MA AIN PICTURE
101
1  PIP FREEZEE
102
2  PIP STEP UPP
103
3  PIP STEP DOOWN
118
8  SUB MODE
119
9  OPTIONS BU US MODE
123
3  CONNECT
124
4  DISCONNEC CT

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

Interfacing IR Receiver to uC. IR


 KuPuC‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬
K"0"=On | "1" = off–‫א‬‫א‬‫א‬‫א‬‫א‬‫ א‬ J1
K"1"‫א‬‫א‬EinactivityF‫א‬  J2
‫א‬‫א‬‫א‬  J3
   ،      ‫א‬ ‫א‬     ‫א‬
K14‫א‬‫א‬
،‫א‬‫א‬‫א‬‫א‬  J4
‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬،
 4.752mS،‫א‬‫א‬‫א‬‫א‬
K1.728mS‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬
K‫א‬‫א‬‫א‬‫א‬

 
CLRM-2038S IR Module CLRM-2038S‫א‬‫א‬‫א‬
 W‫א‬‫א‬‫א‬‫א‬CLRM-2038S‫א‬‫א‬‫א‬
K‫א‬‫א‬‫א‬  J1
KPCM‫א‬‫א‬‫א‬  J2
K‫א‬‫א‬‫א‬  J3
K‫א‬‫א‬‫א‬‫א‬  J4
K2.7V~5.5V‫א‬‫ א‬ J5
KTTL, CMOS‫א‬‫א‬‫א‬  J6
KNEC code,RC5 code‫א‬  J7
K38KHZ‫א‬  J8
  Faculty of Electrical and Electronic Eng.
 
  15   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

K12m ‫א‬  J9
  J10
W‫א‬‫א‬‫א‬‫א‬
 •
KEOpticaal switchF 
CR, CD, MD, DVD, ettcW‫א‬ •
KAudio, TV, VC
Air-connditioner, Fan, CATV, etcW‫א‬‫• א‬

Pinns Config. & Internall Diagram CLRM-22038S


‫א‬‫א‬‫א‬
‫א‬‫א‬

KCLRM-20338S ‫א‬‫א‬‫א‬‫א‬
‫א‬

 
 
 KCLRM--2038S‫א‬‫א‬
‫א‬‫א‬
‫א‬

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

Rc5 receiver interface ‫א‬‫א‬‫א‬‫א‬‫א‬


‫א‬‫א‬‫א‬4.7uF،‫א‬‫א‬
‫א‬‫א‬‫א‬‫א‬‫א‬K‫א‬،‫א‬
 K‫א‬
 

 
 
IRSAT Remote Control  IRSAT‫א‬
W‫א‬‫א‬
 IRSAT RC5 TV Remote Control with 33 KeysW‫• א‬
  China (mainland) W‫א‬ •
AA x 2W‫א‬ •
10 metersW‫א‬ •
K3μ AWStandby current •
17x4.7x2.5cmW‫• א‬
 
IRSAT Remote Control Key Commands  IRSAT‫א‬‫א‬
‫א‬‫א‬‫א‬ ‫א‬‫א‬‫א‬
W‫א‬‫א‬

  Faculty of Electrical and Electronic Eng.
 
  17   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 

COMMAN
ND (in Hex)  DESCRIPTTION of FUNC
CTION 
0
0‐9  NUMEERIC KEYS 0 ‐‐ 9 
1
12 
1
13 
1
14 
1
16  VOLLUME UP   
1
17  VOLUME DOWN   

1
18 

1
19 

2
20 

2
21 

22 
2 BASS UP 
2
23  BA
ASS DOWN 
2
24 

2
25 

2
26 

2
27 

4
48 

5
50 
52 
5 F1 
5
53  F2 
5
54  F3 
5
55  F4 
6
63 
7
71 

RCC5 Sender  R


RC5‫א‬
 W‫א‬
 ‫א‬‫א‬OC1(A)‫א‬‫א‬‫א‬
W‫א‬
‫א‬
‫א‬

 

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

 WBascom-AVR‫א‬‫א‬
   ‫א‬ ‫א‬ ‫א‬  ‫א‬ RC5   ‫א‬ ‫א‬  
 K‫א‬
  Timer1 ‫א‬   ‫א‬ RC5SEND ‫א‬ ‫א‬ ‫א‬  
 K‫א‬
$regfile = "m8def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency

Dim Togbit As Byte , Command As Byte , Address As Byte

Command = 12 ' power on off


Togbit = 0 ' make it 0 or 32 to set the toggle bit
Address = 0

Do
Waitms 200
Rc5send Togbit , Address , Command
Loop

End
 
RC5 Receiver  RC5‫א‬‫א‬
 W‫א‬‫א‬‫א‬
 W‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬‫א‬

 
 
 KBascom-AVR‫א‬‫א‬
   ‫א‬ ‫א‬ ‫א‬  ‫א‬ RC5   ‫א‬ ‫א‬  
 K‫א‬
‫א‬ Timer0‫א‬‫א‬ getrc5‫א‬‫א‬‫א‬
 K
 
  Faculty of Electrical and Electronic Eng.
 
  19   Automatic Control & Automation Dept.
  
‫א‬‫א‬  ‫א‬‫א‬
‫א‬
 
$r
regfile = "m8def.da
at" ' speci
ify the us
sed micro
$c
crystal = 4000000 ' used crystal frequency
f
$b
baud = 19200 ' use b
baud rate
$l
lib "mcsby
yte.lbx"

Co
onfig Rc5 = Pind.2 ' pin
n we want to use fo
or the rec
ceiver inp
put

En
nable Inte
errupts ' ena
able the interrupt
i s
Di
im Address
s As Byte , Command
d As Byte 'rese
erve space
e for variables

Pr
rint "Wait
ting for RC5..."
R

Do
o
Getrc5(ad
ddress , Command)
C ' che
eck if a key
k on the
e remote is
i pressed
d

If Addres
ss = 0 The
en 'we check
c for the TV ad
ddress and
d that is
Comman
nd = Comma
and And &B
B01111111 'clea
ar the tog
ggle bit (
(bit7)
Print Address ; " " ; Command
C
End If
Lo
oop
En
nd

Red: AGC pulses s (ON)


Blue: Check
C bit (fflipping)
Whitte: Addresss (00)
Greeen: Comm mand

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

You might also like