尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
 
	
   	
  
2016	
  
Lab3	
  
SWITCH	
  CONTROL	
  AND	
  TIME	
  DELAY	
  
ARIEL	
  TONATIUH	
  ESPINDOLA	
  PIZANO	
  	
  	
  	
  	
  	
  1459342	
  
Microcontroller  Units   Tongji  University   2	
  
Switch  Control  and  Time  Delay  
	
  
1.   LEDs  and  switches  
2.   Keypad  and  LEDs  
3.   Keypad  and  8-­segment  LED  
	
  
Objective    
  
The  aim  of  this  practice  is  to  understand  how  the  switches,  keypad-­16  and  8-­segment  led  work  
with  the  MC9S08AW60.  Use  the  C  language  and  Assembly  language  to  develop  the  code.  
	
  
1.  LEDs  and  switches    
	
  
Write   a   program,   with   more   controls   of   Switches/LEDs,   using   delay   subroutine   to   control   the  
timing.  Debug  and  run  with  the  Lab  board.  
  
For  example:  Use  two  switches  to  control  two  LEDs    
•   if  one  of  the  two  switches  are  closed,  the  two  LEDs  wink  in  turn    
•   if  both  switches  are  opened,  the  LEDs  are  always  off    
•   if  both  switches  are  closed,  the  LEDs  are  always  on  
  
1.1  Algorithm  
  
In  order  to  do  the  wink,  it  is  necessary  to  figure  out  how  long  the  LEDs  will  stay  turned  on  and  
turned  off.  To  do  so,  the  first  given  parameter  is  the  Bus  Clock  Frequency  which  is  one-­half  the  
CPU  Clock  Frequency.  According  to  the  MCU’s  datasheet,  the  𝑓"  bus  frequency  is  set  at  4MHz  
after  reset.  That  means  that  it  takes  0.25	
  µμ 𝑠  long  per  cycle.  
  
  
Figure  1.1.1.-­  Debugging  the  C  code  with  the  Assembly  component.  
Microcontroller  Units   Tongji  University   3	
  
Time  delay  
  
The  calculation  of  time  delayed  will  be  so  that  the  number  of  machine  cycles  spend  the  time  
required  (e.g.  500ms).  If  we  have  a  loop  that  spends  50  machine  cycles  per  iteration  where  it  
iterates  from  0  to  79.  In  total  we  have  50x80=4000  machine  cycles  spent.  
  
If  we  want  to  delay  1  second  according  to  the  𝑓" = 4𝑀𝐻𝑧  means  that  4000,000  machine  cycles  
must  be  spent.  This  can  be  solved  by  nesting  the  loop  of  4000  cycles  (80  iterations)  in  an  outer  
loop  of  1000  iterations  to  finally  get  the  4M  machine  cycles.    
  
Wink  in  turn  
	
  
To  alternate  the  blinking  between  two  LEDs  can  be  done  by  setting  them  as  a  complement  each  
other.  For  instance,  if  LED0  =  high  then  LED1  =  low  and  vice  versa.    
	
  
Step  by  step  algorithm  
  
1.   Setup  the  PORT  of  MCU  which  is  going  to  be  used.  
2.   Read  the  PORT  and  get  just  the  input  pins.  (AND  operation  suggested)  
3.   If  two  switches  PTAD4  and  PTAD3  are  closed,  then  PTAD7  and  PTAD6  always  on.  
4.   If  two  switches  PTAD4  and  PTAD3  are  opened,  then  PTAD7  and  PTAD6  always  off.  
5.   If  two  switches  PTAD4  or  PTAD3  are  closed,  then  PTAD7  and  PTAD6  wink  in  turn.  
6.   Back  to  the  step  2.  
	
  
Pseudo-­code  
If(inputs == ‘closed’)
Then
alwaysON();
else (inputs == ‘opened’)
Then
alwaysOFF();
else
if(input1 == ‘closed’ or input2==’closed’)
Then
Wink();
end
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Figure  1.1.2.-­  Flow  chart  of  the  algorithm  described  above.  
	
  
Start	
  
Read	
  
PORT	
   closed	
  
Both	
  ON	
  	
  
opened	
  
no	
  
yes	
  
Both	
  OFF	
  	
  
yes	
  
no	
  
Wink	
  	
  	
  
Microcontroller  Units   Tongji  University   4	
  
Implementation  in  C  language  for  the  Lab3.1:  
	
  
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
void delay_ms(int delay){
int i,j;
for(i=0; i<delay; i++){
for(j=0; j<80; j++);
}
}
void wink(int delay){
PTAD_PTAD6 = ~PTAD_PTAD6;
PTAD_PTAD7 = ~PTAD_PTAD6;
delay_ms(delay);
}
void alwaysOn(){
PTAD_PTAD7 = 0;
PTAD_PTAD6 = PTAD_PTAD7;
}
void alwaysOff(){
PTAD_PTAD7 = 1;
PTAD_PTAD6 = PTAD_PTAD7;
}
void main(void) {
//EnableInterrupts; /* enable interrupts */
unsigned char COND = 0x00;
PTADD = 0xF0;
PTAD = 0xFF;
SOPT = 0x53;
for(;;) {
COND = 0x0F & PTAD;
switch(COND){
case 0x03: //0011
alwaysOn();
break;
case 0x0F:
alwaysOff();
break;
default:
if(COND == 0x0B || COND == 0x07)
wink(1000);
break;
Microcontroller  Units   Tongji  University   5	
  
}
} /* loop forever */
}
	
  
2.  Keypad  and  LEDs  
  
Write  a  program  to  detect  key-­pressing,  and  change  LEDs’  status  according  to  the  key  position.  
This  means  that  a  pressed  key  must  be  detected  by  its  coordinates  and  then  encoded  to  4  bits  in  
order  to  show  the  result  in  4  LEDs.  
  
2.1  Algorithms  
  
There  are  two  functions,  one  to  find  the  coordinates  of  the  pressed  key  and  other  to  encode  the  
result  from  a  combination  of  16  possible  keys  (input)  to  4  bits(output).  
  
Row-­detection  
  
The  idea  is  sending  a  logic  0  to  every  single  pin  of  the  PORT  where  is  connected  the  Keypad  in  
order  to  detect  the  column  as  rotating  the  zero  to  the  left  N  times,  where  N  stands  for  the  number  
of  rows.  
  
Encoding  
  
Once  we  have  the  coordinate  of  the  pressed  key,  it  must  be  encoded  to  4  bits  to  the  purpose  of  
being  showed  up  by  the  LEDs.  Since  we  are  dealing  with  a  16-­keyboard,  the  encoding  is  as  
follows:  
Figure  2.1.1.-­  This  logic  diagram  only  illustrates  symbolically  the  encoding  made  by  the  look-­up  
table.  The  binary  encoder  is  not  actually  implemented  in  the  assembly  code.    
Figure  2.1.2.-­  Depiction  of  the  Keypad  coordinates  in  Hexadecimal.  Image  taken  from  Lecture  5-­
2  PPT,  slide  12.  
0
EE
1
DE
2
BE
3
7E
4
ED
5
DD
6
BD
7
7D
8
EB
9
DB
A
BB
B
7B
C
E7
D
D7
E
B7
F
77
2/
→ 𝑛	
  
Encode	
  
output:	
   𝑛	
   𝑏 𝑖𝑡𝑠	
  input:	
  2/
	
   𝑏 𝑖𝑡𝑠	
  
Microcontroller  Units   Tongji  University   6	
  
Row-­detection  algorithm  step  by  step:  
  
1.   Setup  PORTF  of  the  MCU    
a.   Higher  bits  as  inputs  (columns)  
b.   Lower  bits  as  outputs  (rows)  
2.   Initialize  the  port  (Set  the  whole  port  to  logic  one  0xFF)  
3.   Read  the  PORT  
4.   Check  for  key  pressed  
a.   Take  the  higher  bits  
b.   Drop  the  lower  bits  
c.   In  assembly  would  be:  CBEQA  #$F0,  NO_KEY_PRESSED  
5.   If  no  key  pressed,  then  go  back  to  step  2.  
6.   If  key  pressed,  continue  to  step  7.  
7.   Rotate  a  logic  0  bit  from  PORTF0(right)  to  PORTF3(left)(4  rows)  once.  
8.   Do  the  step  3  and  4.  
9.   If  no  key  pressed,  go  back  to  step  7.  
10.  If  key  pressed  detected  (higher  bits),  the  key  value  has  been  founded  then  return  the  value  
of  PORTF.    
11.  Encode    
Look-­up  table  algorithm  step  by  step  (encoding):  
  
1.   Define  a  table  as  shown  in  the  Figure  2.1.2.    
2.   Initialize  the  H:X  index  register  of  the  MCU  from  #$0000  (offset)  
3.   Take  the  value  out  from  KBTABLE  according  to  the  position  pointed  by  H:X  register.  
4.   If  the  taken  value  is  #$00,  return  #$FF  indicating  that  the  fetched  value  is  not  defined  in  
the  table.  
5.   If  the  taken  value  is  not  #$00,  compare  it  to  the  KBVALUE  (returned  by  the  row-­detection  
algorithm)  which  bears  the  coordinate  of  the  pressed  key.  
6.   If  the  value  from  KBTABLE  is  not  equal  to  KBVALUE,  increment  index  by  two  and  go  back  
to  step  3.  
7.   If  the  condition  of  step  6  is  false,  increment  the  index  by  one  and  load  the  value  pointed  
by.  
8.   Return  the  value  loaded  of  step  7.  
  
  
Figure  2.1.3.-­  Debugging  the  code  for  PORTF  initialization  
  
Microcontroller  Units   Tongji  University   7	
  
  
Flow  chart  for  Row-­Detection  Algorithm  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
Flow  chart  for  Look-­up  table  algorithm  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
Setup	
  
PORTF	
  
Start  
Initialize	
  
PORTF	
  
Read	
  	
  
PORTF	
  
Key	
  
pressed?	
  
no	
  
yes	
  
Rotate	
  1	
  bit	
  left	
  
of	
  TMPVAR	
  
Read	
  	
  
PORTF	
  
Key	
  
pressed?	
  
no	
  
yes	
  
Return	
  
KBVALUE	
  
END  
Start  
Define	
  	
  
KBTABLE	
  
Initialize	
  	
  
H:X	
  Register	
  
Load	
  value	
  pointed	
  
by	
  H:X	
  from	
  KBTABLE	
  
BEQ	
  
Z	
  =	
  1?	
  
Return	
  #$FF	
  
(Not	
  found)	
  
END  
no	
  
yes	
  
KBTABLE	
  !=	
  
KBVALUE?	
  
(fetched)	
  
Increment	
  	
  
(H:X)	
  by	
  2	
  
Increment	
  	
  
(H:X)	
  by	
  1	
  
yes	
  
no	
  
Load	
  value	
  
pointed	
  by	
  (H:X)	
  
Return	
  #$FF	
  
(Not	
  found)	
   END  
Microcontroller  Units   Tongji  University   8	
  
Assembly  code  for  Lab  3.2  Keypad  and  LEDs:  
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
;
; export symbols
;
XDEF _Startup
ABSENTRY _Startup
;
; variable/data section
;
ORG Z_RAMStart ; Insert your data definition here
TMPVAR: DS.B 1
KBVALUE: DS.B 1
;-- LOOKUP TABLE---
KBTABLE:
DC.B $7E,$00,$BE,$10,$DE,$20,$EE,$30
DC.B $7D,$40,$BD,$50,$DD,$60,$ED,$70
DC.B $7B,$80,$BB,$90,$DB,$A0,$EB,$B0
DC.B $77,$C0,$B7,$D0,$D7,$E0,$E7,$F0
DC.B $00
;
; code section
;
ORG ROMStart
_Startup:
LDHX #RAMEnd+1 ; initialize the stack pointer
TXS
MOV #$FF,PTAD
MOV #$F0,PTADD
LDA #$53 ; disable watchdog
STA SOPT
PTF_INIT: LDA #$00 ; init data port F
STA PTFD ; init data direction port F
LDA #$0F ; inputs, outputs
STA PTFDD ; COL = 0, ROW = F
LDA #$F0
STA PTFPE ; PULL-UP for columns(inputs)
mainLoop:
JSR KBA
STA KBVALUE
JSR ENCODE
; DO SOMETHING
CBEQA #$FF,display
COMA
display: STA PTAD
BRA mainLoop
;----- row scan KEY-PRESSED detection-----
; variable: KBVALUE
; entry: A
Microcontroller  Units   Tongji  University   9	
  
KBA:
MOV #$FE,TMPVAR ;%11111110
LDX #$04 ; scan 4 rows
KB1:
LDA PTFD ; read PORTF
ORA #$0F ; %00001111 keep columns(H), SET rows(L)
AND TMPVAR
STA PTFD ; row value obtained(L)
NOP
NOP
LDA PTFD ; read PORTF
AND #$F0 ; %11110000 keep columns(H) CLEAR rows(L)
CBEQA #$F0,KB2 ; if not key pressed, go to KB2
LDA PTFD ; if pressed, then store the value in A
BRA KB3
KB2:
SEC ; SET CARRY BIT = 1
ROL TMPVAR ; SHIFT ZERO TO LEFT means: going through the
rows
DBNZX KB1 ; go back and check if changes the PORTFD(High)
and (Low)
LDA #$FF ; if no key pressed
KB3: RTS
;----------------------------------------------
;----- KEY SYMBOLL LOOK UP -----
; input parameter: KBVALUE
; output:A = key coded
ENCODE:
LDHX #$0000
ENC1:
LDA KBTABLE,X
BEQ ENC3 ; if Z = 1
CMP KBVALUE ; if not, compare
BNE ENC2 ; if not eq, jump to ENC2
INCX
LDA KBTABLE,X
BRA RETURN
ENC2:
INCX
INCX
BRA ENC1
ENC3:
LDA #$FF; ; FF for undefined value
RETURN:
RTS
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
Microcontroller  Units   Tongji  University   10	
  
;**************************************************************
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
  
	
  
3.  Keypad  and  8-­segment  LED  
  
Write  a  program  that  detect  the  pressed  key  and  change  8-­segment  LED’s  status  by  showing  the  
corresponding  number  assigned  to  the  key.  
  
To  connect  the  8-­segment  LED  is  required  to  use  another  PORT  than  PORTA  and  PORTF,  so  
PORTB  is  available.  
  
2.1  Algorithms  
	
  
Same	
  as	
  Lab3.2.	
  Row-­‐detection	
  and	
  Look-­‐up	
  table,	
  the	
  only	
  difference	
  is	
  the	
  KBTABLE	
  which	
  now	
  
bears	
  the	
  code	
  depicted	
  by	
  Table	
  2.3.1.	
  
	
  
  
Table  2.3.1.-­  Decodification  from  4-­bit  numbers  to  8-­bit  Display  respectively.  
	
  
To	
  implement	
  this	
  program,	
  is	
  pretty	
  much	
  the	
  same	
  as	
  the	
  last	
  section	
  just	
  by	
  replacing	
  the	
  
KBTABLE	
  by	
  the	
  Table	
  2.3.1.	
  
Number   h   g   f   e   d   c   b   a   Code  
0   0   0   1   1   1   1   1   1   0x3F  
1   0   0   0   0   0   1   1   0   0x06  
2   0   1   0   1   1   0   1   1   0x5B  
3   0   1   0   0   1   1   1   1   0x4F  
4   0   1   1   0   0   1   1   0   0x66  
5   0   1   1   0   1   1   0   1   0x6D  
6   0   1   1   1   1   1   0   1   0x7D  
7   0   0   0   0   0   1   1   1   0x07  
8   0   1   1   1   1   1   1   1   0x7F  
9   0   1   1   0   1   1   1   1   0x6F  
A   0   1   1   1   0   1   1   1   0x77  
B   0   1   1   1   1   1   0   0   0x7C  
C   0   1   0   1   1   0   0   0   0x58  
D   0   1   0   1   1   1   1   0   0x5E  
E   0   1   1   1   1   0   0   1   0x79  
F   0   1   1   1   0   0   0   1   0x71  
Microcontroller  Units   Tongji  University   11	
  
	
  
	
  
Figure  2.3.1.-­    By  debugging  the  code  and  pressing  the  key  corresponding  to  number  3  is  
depicted  the  0xEE  in  the  image  highlighted  with  red  color.  
	
  
Assembly  code  for  Lab  3.3  Keypad,  8-­segments  Display  and  4  LEDS  
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
;
XDEF _Startup
ABSENTRY _Startup
ORG Z_RAMStart ; Insert your data definition here
TMPVAR: DS.B 1
KBVALUE: DS.B 1
KBLEDS: DS.B 1
KB7SEG: DS.B 1
;-- LOOKUP TABLE---
KBTABLE2: ; table for 4 LEDs
DC.B $7E,$00,$BE,$10,$DE,$20,$EE,$30
DC.B $7D,$40,$BD,$50,$DD,$60,$ED,$70
DC.B $7B,$80,$BB,$90,$DB,$A0,$EB,$B0
DC.B $77,$C0,$B7,$D0,$D7,$E0,$E7,$F0
DC.B $00
KBTABLE: ; table for 8-segments LED
DC.B $7E,$3F,$BE,$06,$DE,$5B,$EE,$4F
DC.B $7D,$66,$BD,$6D,$DD,$7D,$ED,$07
DC.B $7B,$7F,$BB,$6F,$DB,$77,$EB,$7C
DC.B $77,$58,$B7,$5E,$D7,$79,$E7,$71
DC.B $00
ORG ROMStart
_Startup:
LDHX #RAMEnd+1 ; initialize the stack pointer
TXS
MOV #$FF,PTAD
MOV #$F0,PTADD
MOV #$00,PTBD
MOV #$FF,PTBDD
LDA #$53 ; disable watchdog
STA SOPT
PTF_INIT: LDA #$00 ; init data port F
Microcontroller  Units   Tongji  University   12	
  
STA PTFD ; init data direction port F
LDA #$0F ; inputs, outputs
STA PTFDD ; COL = 0, ROW = F
LDA #$F0
STA PTFPE ; PULL-UP for columns(inputs)
mainLoop:
JSR KBA
STA KBVALUE
JSR ENCODE
STA KB7SEG
JSR ENCODE2
STA KBLEDS
LDA KB7SEG
CBEQA #$FF,clear ; if no key pressed
STA PTBD
LDA KBLEDS
COMA
STA PTAD
BRA back
clear: MOV #$00,PTBD
MOV #$FF,PTAD
back BRA mainLoop
;----- row scan KEY-PRESSED detection-----
; variable: KBVALUE
; entry: A
KBA:
MOV #$FE,TMPVAR ;%11111110
LDX #$04 ; scan 4 rows
KB1:
LDA PTFD ; read PORTF
ORA #$0F ; %00001111 keep columns(H), SET rows(L)
AND TMPVAR
STA PTFD ; row value obtained(L)
NOP
NOP
LDA PTFD ; read PORTF
AND #$F0 ; %11110000 keep columns(H) CLEAR rows(L)
CBEQA #$F0,KB2 ; if not key pressed, go to KB2
LDA PTFD ; if pressed, then store the value in A
BRA KB3
KB2:
SEC ; SET CARRY BIT = 1
ROL TMPVAR ; SHIFT ZERO TO LEFT means: going through the
rows
DBNZX KB1 ; go back and check if changes the PORTFD(High)
and (Low)
LDA #$FF ; if no key pressed
KB3: RTS
;----------------------------------------------
;----- KEY SYMBOLL LOOK UP -----
; input parameter: KBVALUE
; output:VALUE CODED FOR 8-SEGMENT LED
ENCODE:
Microcontroller  Units   Tongji  University   13	
  
LDHX #$0000
ENC1:
LDA KBTABLE,X
BEQ ENC3 ; if Z = 1
CMP KBVALUE ; if not, compare
BNE ENC2 ; if not eq, jump to ENC2
INCX
LDA KBTABLE,X
BRA RETURN
ENC2:
INCX
INCX
BRA ENC1
ENC3:
LDA #$FF; ; FF for undefined value
RETURN:
RTS
;----------------------------------------------
;----- KEY SYMBOLL LOOK UP -----
; input parameter: KBVALUE
; output:VALUE CODED FOR 4 BITS, SO 4 LEDS
ENCODE2:
LDHX #$0000
ENC21:
LDA KBTABLE2,X
BEQ ENC23 ; if Z = 1
CMP KBVALUE ; if not, compare
BNE ENC22 ; if not eq, jump to ENC2
INCX
LDA KBTABLE2,X
BRA RETURN2
ENC22:
INCX
INCX
BRA ENC21
ENC23:
LDA #$FF; ; FF for undefined value
RETURN2:
RTS
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFA
Microcontroller  Units   Tongji  University   14	
  
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
	
  
  
Results  with  Video  attached  to  the  e-­mail:  
  
  

More Related Content

What's hot

Coding verilog
Coding verilogCoding verilog
Coding verilog
umarjamil10000
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
Pantech ProLabs India Pvt Ltd
 
Lecture1 The 8085 Microprocessor
Lecture1 The 8085 MicroprocessorLecture1 The 8085 Microprocessor
Lecture1 The 8085 Microprocessor
Zeeshan Ahmed
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
Béo Tú
 
Lecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of InstructionsLecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of Instructions
Zeeshan Ahmed
 
Lecture 02 Data Group of Instructions
Lecture 02 Data Group of InstructionsLecture 02 Data Group of Instructions
Lecture 02 Data Group of Instructions
Zeeshan Ahmed
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
Ikhwan_Fakrudin
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
Devi Pradeep Podugu
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
艾鍗科技
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)
Selomon birhane
 
03 shift registers_and_more_data_manipulation_sp15
03 shift registers_and_more_data_manipulation_sp1503 shift registers_and_more_data_manipulation_sp15
03 shift registers_and_more_data_manipulation_sp15
John Todora
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)
Dr. Swaminathan Kathirvel
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
anand hd
 
17443 microprocessor
17443   microprocessor17443   microprocessor
17443 microprocessor
soni_nits
 
Logic Fe Tcom
Logic Fe TcomLogic Fe Tcom
Logic Fe Tcom
Mukesh Mishra
 
Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded C
Varun A M
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
Shankar Gangaju
 
Logic Design - Chapter 5: Part1 Combinattional Logic
Logic Design - Chapter 5: Part1 Combinattional LogicLogic Design - Chapter 5: Part1 Combinattional Logic
Logic Design - Chapter 5: Part1 Combinattional Logic
Gouda Mando
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
Mohamed Abdallah
 

What's hot (20)

Coding verilog
Coding verilogCoding verilog
Coding verilog
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
Lecture1 The 8085 Microprocessor
Lecture1 The 8085 MicroprocessorLecture1 The 8085 Microprocessor
Lecture1 The 8085 Microprocessor
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
Lecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of InstructionsLecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of Instructions
 
Lecture 02 Data Group of Instructions
Lecture 02 Data Group of InstructionsLecture 02 Data Group of Instructions
Lecture 02 Data Group of Instructions
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)N_Asm Assembly arithmetic instructions (sol)
N_Asm Assembly arithmetic instructions (sol)
 
03 shift registers_and_more_data_manipulation_sp15
03 shift registers_and_more_data_manipulation_sp1503 shift registers_and_more_data_manipulation_sp15
03 shift registers_and_more_data_manipulation_sp15
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
17443 microprocessor
17443   microprocessor17443   microprocessor
17443 microprocessor
 
Logic Fe Tcom
Logic Fe TcomLogic Fe Tcom
Logic Fe Tcom
 
Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded C
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
 
Logic Design - Chapter 5: Part1 Combinattional Logic
Logic Design - Chapter 5: Part1 Combinattional LogicLogic Design - Chapter 5: Part1 Combinattional Logic
Logic Design - Chapter 5: Part1 Combinattional Logic
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 

Similar to Switch Control and Time Delay - Keypad

Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
Ariel Tonatiuh Espindola
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
Ariel Tonatiuh Espindola
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
nanocdac
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
Mashood
 
Jp
Jp Jp
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Bharat Biyani
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manual
Dhaval Shukla
 
ECET 340 Effective Communication/tutorialrank.com
 ECET 340 Effective Communication/tutorialrank.com ECET 340 Effective Communication/tutorialrank.com
ECET 340 Effective Communication/tutorialrank.com
jonhson203
 
20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx
PerumalPitchandi
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
Hari Prakash
 
Micro Processor Lab Manual!
Micro Processor Lab Manual!Micro Processor Lab Manual!
Micro Processor Lab Manual!
PRABHAHARAN429
 
Ecet 340 Teaching Effectively--tutorialrank.com
Ecet 340 Teaching Effectively--tutorialrank.comEcet 340 Teaching Effectively--tutorialrank.com
Ecet 340 Teaching Effectively--tutorialrank.com
Soaps97
 
Mpi lab manual eee
Mpi lab manual eeeMpi lab manual eee
Mpi lab manual eee
Vivek Kumar Sinha
 
publish manual
publish manualpublish manual
publish manual
John Webster
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
DHEERAJ DHAKAR
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)
Basil John
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.com
amaranthbeg60
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.com
amaranthbeg80
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.com
amaranthbeg120
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.com
amaranthbeg100
 

Similar to Switch Control and Time Delay - Keypad (20)

Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
Jp
Jp Jp
Jp
 
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manual
 
ECET 340 Effective Communication/tutorialrank.com
 ECET 340 Effective Communication/tutorialrank.com ECET 340 Effective Communication/tutorialrank.com
ECET 340 Effective Communication/tutorialrank.com
 
20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
 
Micro Processor Lab Manual!
Micro Processor Lab Manual!Micro Processor Lab Manual!
Micro Processor Lab Manual!
 
Ecet 340 Teaching Effectively--tutorialrank.com
Ecet 340 Teaching Effectively--tutorialrank.comEcet 340 Teaching Effectively--tutorialrank.com
Ecet 340 Teaching Effectively--tutorialrank.com
 
Mpi lab manual eee
Mpi lab manual eeeMpi lab manual eee
Mpi lab manual eee
 
publish manual
publish manualpublish manual
publish manual
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.com
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.com
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.com
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.com
 

Recently uploaded

SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
Tsuyoshi Horigome
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
Guangdong Ctube Industry Co., Ltd.
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
LokerXu2
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
NaveenNaveen726446
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUESAN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
drshikhapandey2022
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
dulbh kashyap
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
ShurooqTaib
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
simrangupta87541
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
Ismail Sultan
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
yakranividhrini
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
sonamrawat5631
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
DebendraDevKhanal1
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
Pallavi Sharma
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
hotchicksescort
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Tsuyoshi Horigome
 
Microsoft Azure AD architecture and features
Microsoft Azure AD architecture and featuresMicrosoft Azure AD architecture and features
Microsoft Azure AD architecture and features
ssuser381403
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine
 

Recently uploaded (20)

SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUESAN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
 
Microsoft Azure AD architecture and features
Microsoft Azure AD architecture and featuresMicrosoft Azure AD architecture and features
Microsoft Azure AD architecture and features
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
 

Switch Control and Time Delay - Keypad

  • 1.       2016   Lab3   SWITCH  CONTROL  AND  TIME  DELAY   ARIEL  TONATIUH  ESPINDOLA  PIZANO            1459342  
  • 2. Microcontroller  Units   Tongji  University   2   Switch  Control  and  Time  Delay     1.   LEDs  and  switches   2.   Keypad  and  LEDs   3.   Keypad  and  8-­segment  LED     Objective       The  aim  of  this  practice  is  to  understand  how  the  switches,  keypad-­16  and  8-­segment  led  work   with  the  MC9S08AW60.  Use  the  C  language  and  Assembly  language  to  develop  the  code.     1.  LEDs  and  switches       Write   a   program,   with   more   controls   of   Switches/LEDs,   using   delay   subroutine   to   control   the   timing.  Debug  and  run  with  the  Lab  board.     For  example:  Use  two  switches  to  control  two  LEDs     •   if  one  of  the  two  switches  are  closed,  the  two  LEDs  wink  in  turn     •   if  both  switches  are  opened,  the  LEDs  are  always  off     •   if  both  switches  are  closed,  the  LEDs  are  always  on     1.1  Algorithm     In  order  to  do  the  wink,  it  is  necessary  to  figure  out  how  long  the  LEDs  will  stay  turned  on  and   turned  off.  To  do  so,  the  first  given  parameter  is  the  Bus  Clock  Frequency  which  is  one-­half  the   CPU  Clock  Frequency.  According  to  the  MCU’s  datasheet,  the  𝑓"  bus  frequency  is  set  at  4MHz   after  reset.  That  means  that  it  takes  0.25  µμ 𝑠  long  per  cycle.       Figure  1.1.1.-­  Debugging  the  C  code  with  the  Assembly  component.  
  • 3. Microcontroller  Units   Tongji  University   3   Time  delay     The  calculation  of  time  delayed  will  be  so  that  the  number  of  machine  cycles  spend  the  time   required  (e.g.  500ms).  If  we  have  a  loop  that  spends  50  machine  cycles  per  iteration  where  it   iterates  from  0  to  79.  In  total  we  have  50x80=4000  machine  cycles  spent.     If  we  want  to  delay  1  second  according  to  the  𝑓" = 4𝑀𝐻𝑧  means  that  4000,000  machine  cycles   must  be  spent.  This  can  be  solved  by  nesting  the  loop  of  4000  cycles  (80  iterations)  in  an  outer   loop  of  1000  iterations  to  finally  get  the  4M  machine  cycles.       Wink  in  turn     To  alternate  the  blinking  between  two  LEDs  can  be  done  by  setting  them  as  a  complement  each   other.  For  instance,  if  LED0  =  high  then  LED1  =  low  and  vice  versa.       Step  by  step  algorithm     1.   Setup  the  PORT  of  MCU  which  is  going  to  be  used.   2.   Read  the  PORT  and  get  just  the  input  pins.  (AND  operation  suggested)   3.   If  two  switches  PTAD4  and  PTAD3  are  closed,  then  PTAD7  and  PTAD6  always  on.   4.   If  two  switches  PTAD4  and  PTAD3  are  opened,  then  PTAD7  and  PTAD6  always  off.   5.   If  two  switches  PTAD4  or  PTAD3  are  closed,  then  PTAD7  and  PTAD6  wink  in  turn.   6.   Back  to  the  step  2.     Pseudo-­code   If(inputs == ‘closed’) Then alwaysON(); else (inputs == ‘opened’) Then alwaysOFF(); else if(input1 == ‘closed’ or input2==’closed’) Then Wink(); end                 Figure  1.1.2.-­  Flow  chart  of  the  algorithm  described  above.     Start   Read   PORT   closed   Both  ON     opened   no   yes   Both  OFF     yes   no   Wink      
  • 4. Microcontroller  Units   Tongji  University   4   Implementation  in  C  language  for  the  Lab3.1:     #include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */ void delay_ms(int delay){ int i,j; for(i=0; i<delay; i++){ for(j=0; j<80; j++); } } void wink(int delay){ PTAD_PTAD6 = ~PTAD_PTAD6; PTAD_PTAD7 = ~PTAD_PTAD6; delay_ms(delay); } void alwaysOn(){ PTAD_PTAD7 = 0; PTAD_PTAD6 = PTAD_PTAD7; } void alwaysOff(){ PTAD_PTAD7 = 1; PTAD_PTAD6 = PTAD_PTAD7; } void main(void) { //EnableInterrupts; /* enable interrupts */ unsigned char COND = 0x00; PTADD = 0xF0; PTAD = 0xFF; SOPT = 0x53; for(;;) { COND = 0x0F & PTAD; switch(COND){ case 0x03: //0011 alwaysOn(); break; case 0x0F: alwaysOff(); break; default: if(COND == 0x0B || COND == 0x07) wink(1000); break;
  • 5. Microcontroller  Units   Tongji  University   5   } } /* loop forever */ }   2.  Keypad  and  LEDs     Write  a  program  to  detect  key-­pressing,  and  change  LEDs’  status  according  to  the  key  position.   This  means  that  a  pressed  key  must  be  detected  by  its  coordinates  and  then  encoded  to  4  bits  in   order  to  show  the  result  in  4  LEDs.     2.1  Algorithms     There  are  two  functions,  one  to  find  the  coordinates  of  the  pressed  key  and  other  to  encode  the   result  from  a  combination  of  16  possible  keys  (input)  to  4  bits(output).     Row-­detection     The  idea  is  sending  a  logic  0  to  every  single  pin  of  the  PORT  where  is  connected  the  Keypad  in   order  to  detect  the  column  as  rotating  the  zero  to  the  left  N  times,  where  N  stands  for  the  number   of  rows.     Encoding     Once  we  have  the  coordinate  of  the  pressed  key,  it  must  be  encoded  to  4  bits  to  the  purpose  of   being  showed  up  by  the  LEDs.  Since  we  are  dealing  with  a  16-­keyboard,  the  encoding  is  as   follows:   Figure  2.1.1.-­  This  logic  diagram  only  illustrates  symbolically  the  encoding  made  by  the  look-­up   table.  The  binary  encoder  is  not  actually  implemented  in  the  assembly  code.     Figure  2.1.2.-­  Depiction  of  the  Keypad  coordinates  in  Hexadecimal.  Image  taken  from  Lecture  5-­ 2  PPT,  slide  12.   0 EE 1 DE 2 BE 3 7E 4 ED 5 DD 6 BD 7 7D 8 EB 9 DB A BB B 7B C E7 D D7 E B7 F 77 2/ → 𝑛   Encode   output:   𝑛   𝑏 𝑖𝑡𝑠  input:  2/   𝑏 𝑖𝑡𝑠  
  • 6. Microcontroller  Units   Tongji  University   6   Row-­detection  algorithm  step  by  step:     1.   Setup  PORTF  of  the  MCU     a.   Higher  bits  as  inputs  (columns)   b.   Lower  bits  as  outputs  (rows)   2.   Initialize  the  port  (Set  the  whole  port  to  logic  one  0xFF)   3.   Read  the  PORT   4.   Check  for  key  pressed   a.   Take  the  higher  bits   b.   Drop  the  lower  bits   c.   In  assembly  would  be:  CBEQA  #$F0,  NO_KEY_PRESSED   5.   If  no  key  pressed,  then  go  back  to  step  2.   6.   If  key  pressed,  continue  to  step  7.   7.   Rotate  a  logic  0  bit  from  PORTF0(right)  to  PORTF3(left)(4  rows)  once.   8.   Do  the  step  3  and  4.   9.   If  no  key  pressed,  go  back  to  step  7.   10.  If  key  pressed  detected  (higher  bits),  the  key  value  has  been  founded  then  return  the  value   of  PORTF.     11.  Encode     Look-­up  table  algorithm  step  by  step  (encoding):     1.   Define  a  table  as  shown  in  the  Figure  2.1.2.     2.   Initialize  the  H:X  index  register  of  the  MCU  from  #$0000  (offset)   3.   Take  the  value  out  from  KBTABLE  according  to  the  position  pointed  by  H:X  register.   4.   If  the  taken  value  is  #$00,  return  #$FF  indicating  that  the  fetched  value  is  not  defined  in   the  table.   5.   If  the  taken  value  is  not  #$00,  compare  it  to  the  KBVALUE  (returned  by  the  row-­detection   algorithm)  which  bears  the  coordinate  of  the  pressed  key.   6.   If  the  value  from  KBTABLE  is  not  equal  to  KBVALUE,  increment  index  by  two  and  go  back   to  step  3.   7.   If  the  condition  of  step  6  is  false,  increment  the  index  by  one  and  load  the  value  pointed   by.   8.   Return  the  value  loaded  of  step  7.       Figure  2.1.3.-­  Debugging  the  code  for  PORTF  initialization    
  • 7. Microcontroller  Units   Tongji  University   7     Flow  chart  for  Row-­Detection  Algorithm                                       Flow  chart  for  Look-­up  table  algorithm                                                   Setup   PORTF   Start   Initialize   PORTF   Read     PORTF   Key   pressed?   no   yes   Rotate  1  bit  left   of  TMPVAR   Read     PORTF   Key   pressed?   no   yes   Return   KBVALUE   END   Start   Define     KBTABLE   Initialize     H:X  Register   Load  value  pointed   by  H:X  from  KBTABLE   BEQ   Z  =  1?   Return  #$FF   (Not  found)   END   no   yes   KBTABLE  !=   KBVALUE?   (fetched)   Increment     (H:X)  by  2   Increment     (H:X)  by  1   yes   no   Load  value   pointed  by  (H:X)   Return  #$FF   (Not  found)   END  
  • 8. Microcontroller  Units   Tongji  University   8   Assembly  code  for  Lab  3.2  Keypad  and  LEDs:   ; Include derivative-specific definitions INCLUDE 'derivative.inc' ; ; export symbols ; XDEF _Startup ABSENTRY _Startup ; ; variable/data section ; ORG Z_RAMStart ; Insert your data definition here TMPVAR: DS.B 1 KBVALUE: DS.B 1 ;-- LOOKUP TABLE--- KBTABLE: DC.B $7E,$00,$BE,$10,$DE,$20,$EE,$30 DC.B $7D,$40,$BD,$50,$DD,$60,$ED,$70 DC.B $7B,$80,$BB,$90,$DB,$A0,$EB,$B0 DC.B $77,$C0,$B7,$D0,$D7,$E0,$E7,$F0 DC.B $00 ; ; code section ; ORG ROMStart _Startup: LDHX #RAMEnd+1 ; initialize the stack pointer TXS MOV #$FF,PTAD MOV #$F0,PTADD LDA #$53 ; disable watchdog STA SOPT PTF_INIT: LDA #$00 ; init data port F STA PTFD ; init data direction port F LDA #$0F ; inputs, outputs STA PTFDD ; COL = 0, ROW = F LDA #$F0 STA PTFPE ; PULL-UP for columns(inputs) mainLoop: JSR KBA STA KBVALUE JSR ENCODE ; DO SOMETHING CBEQA #$FF,display COMA display: STA PTAD BRA mainLoop ;----- row scan KEY-PRESSED detection----- ; variable: KBVALUE ; entry: A
  • 9. Microcontroller  Units   Tongji  University   9   KBA: MOV #$FE,TMPVAR ;%11111110 LDX #$04 ; scan 4 rows KB1: LDA PTFD ; read PORTF ORA #$0F ; %00001111 keep columns(H), SET rows(L) AND TMPVAR STA PTFD ; row value obtained(L) NOP NOP LDA PTFD ; read PORTF AND #$F0 ; %11110000 keep columns(H) CLEAR rows(L) CBEQA #$F0,KB2 ; if not key pressed, go to KB2 LDA PTFD ; if pressed, then store the value in A BRA KB3 KB2: SEC ; SET CARRY BIT = 1 ROL TMPVAR ; SHIFT ZERO TO LEFT means: going through the rows DBNZX KB1 ; go back and check if changes the PORTFD(High) and (Low) LDA #$FF ; if no key pressed KB3: RTS ;---------------------------------------------- ;----- KEY SYMBOLL LOOK UP ----- ; input parameter: KBVALUE ; output:A = key coded ENCODE: LDHX #$0000 ENC1: LDA KBTABLE,X BEQ ENC3 ; if Z = 1 CMP KBVALUE ; if not, compare BNE ENC2 ; if not eq, jump to ENC2 INCX LDA KBTABLE,X BRA RETURN ENC2: INCX INCX BRA ENC1 ENC3: LDA #$FF; ; FF for undefined value RETURN: RTS ;************************************************************** ;* spurious - Spurious Interrupt Service Routine. * ;* (unwanted interrupt) * ;************************************************************** spurious: ; placed here so that security value NOP ; does not change all the time. RTI ;************************************************************** ;* Interrupt Vectors *
  • 10. Microcontroller  Units   Tongji  University   10   ;************************************************************** ORG $FFFA DC.W spurious ; DC.W spurious ; SWI DC.W _Startup ; Reset     3.  Keypad  and  8-­segment  LED     Write  a  program  that  detect  the  pressed  key  and  change  8-­segment  LED’s  status  by  showing  the   corresponding  number  assigned  to  the  key.     To  connect  the  8-­segment  LED  is  required  to  use  another  PORT  than  PORTA  and  PORTF,  so   PORTB  is  available.     2.1  Algorithms     Same  as  Lab3.2.  Row-­‐detection  and  Look-­‐up  table,  the  only  difference  is  the  KBTABLE  which  now   bears  the  code  depicted  by  Table  2.3.1.       Table  2.3.1.-­  Decodification  from  4-­bit  numbers  to  8-­bit  Display  respectively.     To  implement  this  program,  is  pretty  much  the  same  as  the  last  section  just  by  replacing  the   KBTABLE  by  the  Table  2.3.1.   Number   h   g   f   e   d   c   b   a   Code   0   0   0   1   1   1   1   1   1   0x3F   1   0   0   0   0   0   1   1   0   0x06   2   0   1   0   1   1   0   1   1   0x5B   3   0   1   0   0   1   1   1   1   0x4F   4   0   1   1   0   0   1   1   0   0x66   5   0   1   1   0   1   1   0   1   0x6D   6   0   1   1   1   1   1   0   1   0x7D   7   0   0   0   0   0   1   1   1   0x07   8   0   1   1   1   1   1   1   1   0x7F   9   0   1   1   0   1   1   1   1   0x6F   A   0   1   1   1   0   1   1   1   0x77   B   0   1   1   1   1   1   0   0   0x7C   C   0   1   0   1   1   0   0   0   0x58   D   0   1   0   1   1   1   1   0   0x5E   E   0   1   1   1   1   0   0   1   0x79   F   0   1   1   1   0   0   0   1   0x71  
  • 11. Microcontroller  Units   Tongji  University   11       Figure  2.3.1.-­    By  debugging  the  code  and  pressing  the  key  corresponding  to  number  3  is   depicted  the  0xEE  in  the  image  highlighted  with  red  color.     Assembly  code  for  Lab  3.3  Keypad,  8-­segments  Display  and  4  LEDS   ; Include derivative-specific definitions INCLUDE 'derivative.inc' ; XDEF _Startup ABSENTRY _Startup ORG Z_RAMStart ; Insert your data definition here TMPVAR: DS.B 1 KBVALUE: DS.B 1 KBLEDS: DS.B 1 KB7SEG: DS.B 1 ;-- LOOKUP TABLE--- KBTABLE2: ; table for 4 LEDs DC.B $7E,$00,$BE,$10,$DE,$20,$EE,$30 DC.B $7D,$40,$BD,$50,$DD,$60,$ED,$70 DC.B $7B,$80,$BB,$90,$DB,$A0,$EB,$B0 DC.B $77,$C0,$B7,$D0,$D7,$E0,$E7,$F0 DC.B $00 KBTABLE: ; table for 8-segments LED DC.B $7E,$3F,$BE,$06,$DE,$5B,$EE,$4F DC.B $7D,$66,$BD,$6D,$DD,$7D,$ED,$07 DC.B $7B,$7F,$BB,$6F,$DB,$77,$EB,$7C DC.B $77,$58,$B7,$5E,$D7,$79,$E7,$71 DC.B $00 ORG ROMStart _Startup: LDHX #RAMEnd+1 ; initialize the stack pointer TXS MOV #$FF,PTAD MOV #$F0,PTADD MOV #$00,PTBD MOV #$FF,PTBDD LDA #$53 ; disable watchdog STA SOPT PTF_INIT: LDA #$00 ; init data port F
  • 12. Microcontroller  Units   Tongji  University   12   STA PTFD ; init data direction port F LDA #$0F ; inputs, outputs STA PTFDD ; COL = 0, ROW = F LDA #$F0 STA PTFPE ; PULL-UP for columns(inputs) mainLoop: JSR KBA STA KBVALUE JSR ENCODE STA KB7SEG JSR ENCODE2 STA KBLEDS LDA KB7SEG CBEQA #$FF,clear ; if no key pressed STA PTBD LDA KBLEDS COMA STA PTAD BRA back clear: MOV #$00,PTBD MOV #$FF,PTAD back BRA mainLoop ;----- row scan KEY-PRESSED detection----- ; variable: KBVALUE ; entry: A KBA: MOV #$FE,TMPVAR ;%11111110 LDX #$04 ; scan 4 rows KB1: LDA PTFD ; read PORTF ORA #$0F ; %00001111 keep columns(H), SET rows(L) AND TMPVAR STA PTFD ; row value obtained(L) NOP NOP LDA PTFD ; read PORTF AND #$F0 ; %11110000 keep columns(H) CLEAR rows(L) CBEQA #$F0,KB2 ; if not key pressed, go to KB2 LDA PTFD ; if pressed, then store the value in A BRA KB3 KB2: SEC ; SET CARRY BIT = 1 ROL TMPVAR ; SHIFT ZERO TO LEFT means: going through the rows DBNZX KB1 ; go back and check if changes the PORTFD(High) and (Low) LDA #$FF ; if no key pressed KB3: RTS ;---------------------------------------------- ;----- KEY SYMBOLL LOOK UP ----- ; input parameter: KBVALUE ; output:VALUE CODED FOR 8-SEGMENT LED ENCODE:
  • 13. Microcontroller  Units   Tongji  University   13   LDHX #$0000 ENC1: LDA KBTABLE,X BEQ ENC3 ; if Z = 1 CMP KBVALUE ; if not, compare BNE ENC2 ; if not eq, jump to ENC2 INCX LDA KBTABLE,X BRA RETURN ENC2: INCX INCX BRA ENC1 ENC3: LDA #$FF; ; FF for undefined value RETURN: RTS ;---------------------------------------------- ;----- KEY SYMBOLL LOOK UP ----- ; input parameter: KBVALUE ; output:VALUE CODED FOR 4 BITS, SO 4 LEDS ENCODE2: LDHX #$0000 ENC21: LDA KBTABLE2,X BEQ ENC23 ; if Z = 1 CMP KBVALUE ; if not, compare BNE ENC22 ; if not eq, jump to ENC2 INCX LDA KBTABLE2,X BRA RETURN2 ENC22: INCX INCX BRA ENC21 ENC23: LDA #$FF; ; FF for undefined value RETURN2: RTS ;************************************************************** ;* spurious - Spurious Interrupt Service Routine. * ;* (unwanted interrupt) * ;************************************************************** spurious: ; placed here so that security value NOP ; does not change all the time. RTI ;************************************************************** ;* Interrupt Vectors * ;************************************************************** ORG $FFFA
  • 14. Microcontroller  Units   Tongji  University   14   DC.W spurious ; DC.W spurious ; SWI DC.W _Startup ; Reset     Results  with  Video  attached  to  the  e-­mail:      
  翻译: