Download presentation
Presentation is loading. Please wait.
1
Parallel Ports Lecture L4.1
2
Parallel Interfacing Parallel I/O Ports Using Parallel Ports
3
Port Integration Module PIM_9C32 Block Guide V01.06 Reference: S12C32PIMV1.pdf
4
Port and Data Direction Registers
5
PTP ($258) DDRP($25A) PTT ($240) DDRT($242) PTM ($250) DDRM($252) PTS ($248) DDRS($24A) PORTA ($0) DDRA ($2) PORTB ($1) DDRB ($3) PTJ ($268) DDRJ($26A) PORTE ($8) DDRE ($9) PORTAD ($8F) Input only
6
Parallel Interfacing Parallel I/O Ports Using Parallel Ports
7
Turning on an LED
8
Using an AC Relay
9
LED Example
10
;LED example ptp equ $258 ; Port P ddrp equ $25A ; Direction ORG$800 pb_maskdb$04 reddb$80 yellowdb$40 greendb$20 red1db$7F yellow1db$BF green1db$DF init ldaa#$E0;PP7..PP5 outputs staaddrp;PP2 input ldaa#0 staaptp;turn off LEDs rts
11
ORG$4000 main bsrinit;initialize port mn0ldx#red;start with red LED mn1bsrsec_delay;wait 1 second ldaaptp oraa0,x staaptp;light next LED inx cpx#$804 bnemn1;light red, yellow, green mn2bsrsec_delay;wait 1 second ldaaptp anda0,x staaptp;turn off next LED inx cpx#$807 bnemn2;turn off red, yellow, green bramn0;repeat sequence
12
#includems_delay.asm init ldaa#$E0;PP7..PP5 outputs staaddrp;PP2 input ldaa#0 staaptp;turn off LEDs rts sec_delay ldy#1000 jsrms_delay rts
13
Interfacing a switch input PTJ: equ $268 ; Port J DDRJ: equ $26A ; Direction ldaaPTJ anda#$80 beqsw_down
14
Debouncing Switch wait_pb_down ldaaptj andapb_mask bnewait_pb_down;wait to push down ldy#3 jsrms_delay;debounce delay ldaaptj andapb_mask bnewait_pb_down;wait until still down rts
15
Debouncing Switch wait_pb_up ldaaptj andapb_mask beqwait_pb_up;wait to release ldy#3 jsrms_delay;debounce delay ldaaptj andapb_mask beqwait_pb_up;wait until still up rts
16
LED – Pushbutton Example
17
;LED and pushbutton example ptp equ $258 ; Port P ddrp equ $25A ; Direction ptj equ $268 ; Port J ddrj equ $26A ; Direction ORG$800 pb_maskdb$80 reddb$80 yellowdb$40 greendb$20 red1db$7F yellow1db$BF green1db$DF ORG$4000 main bsrinit;initialize port
18
ORG$4000 main bsrinit;initialize port ldx#red;start with red LED mn1bsrwait_pb_down;wait to push button ldaaptp oraa0,x staaptp;light next LED bsrwait_pb_up;wait to release button inx cpx#$804 bnemn1;light red, yellow, green mn2bsrwait_pb_down;wait to push button ldaaptp anda0,x staaptp;turn off next LED bsrwait_pb_up;wait to release button inx cpx#$807 bnemn2;turn off red, yellow, green bramain;repeat sequence
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.