1 / 18

Parallel Ports

Parallel Ports. Lecture L4.1. Parallel Interfacing. Parallel I/O Ports Using Parallel Ports. Port Integration Module. Reference:. PIM_9C32 Block Guide V01.06. S12C32PIMV1.pdf. Port and Data Direction Registers. PTT ($240) DDRT($242). PTP ($258) DDRP($25A). PTJ ($268) DDRJ($26A).

Télécharger la présentation

Parallel Ports

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parallel Ports Lecture L4.1

  2. Parallel Interfacing • Parallel I/O Ports • Using Parallel Ports

  3. Port Integration Module Reference: PIM_9C32 Block Guide V01.06 S12C32PIMV1.pdf

  4. Port and Data Direction Registers

  5. PTT ($240) DDRT($242) PTP ($258) DDRP($25A) PTJ ($268) DDRJ($26A) PTS ($248) DDRS($24A) PORTAD ($8F) Input only PTM ($250) DDRM($252) PORTB ($1) DDRB ($3) PORTE ($8) DDRE ($9) PORTA ($0) DDRA ($2)

  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_mask db $04 red db $80 yellow db $40 green db $20 red1 db $7F yellow1 db $BF green1 db $DF init ldaa #$E0 ;PP7..PP5 outputs staa ddrp ;PP2 input ldaa #0 staa ptp ;turn off LEDs rts

  11. ORG $4000 main bsr init ;initialize port mn0 ldx #red ;start with red LED mn1 bsr sec_delay ;wait 1 second ldaa ptp oraa 0,x staa ptp ;light next LED inx cpx #$804 bne mn1 ;light red, yellow, green mn2 bsr sec_delay ;wait 1 second ldaa ptp anda 0,x staa ptp ;turn off next LED inx cpx #$807 bne mn2 ;turn off red, yellow, green bra mn0 ;repeat sequence

  12. #include ms_delay.asm init ldaa #$E0 ;PP7..PP5 outputs staa ddrp ;PP2 input ldaa #0 staa ptp ;turn off LEDs rts sec_delay ldy #1000 jsr ms_delay rts

  13. Interfacing a switch input PTJ: equ $268 ; Port J DDRJ: equ $26A ; Direction ldaa PTJ anda #$80 beq sw_down

  14. Debouncing Switch wait_pb_down ldaa ptj anda pb_mask bne wait_pb_down ;wait to push down ldy #3 jsr ms_delay ;debounce delay ldaa ptj anda pb_mask bne wait_pb_down ;wait until still down rts

  15. Debouncing Switch wait_pb_up ldaa ptj anda pb_mask beq wait_pb_up ;wait to release ldy #3 jsr ms_delay ;debounce delay ldaa ptj anda pb_mask beq wait_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_mask db $80 red db $80 yellow db $40 green db $20 red1 db $7F yellow1 db $BF green1 db $DF ORG $4000 main bsr init ;initialize port

  18. ORG $4000 main bsr init ;initialize port ldx #red ;start with red LED mn1 bsr wait_pb_down ;wait to push button ldaa ptp oraa 0,x staa ptp ;light next LED bsr wait_pb_up ;wait to release button inx cpx #$804 bne mn1 ;light red, yellow, green mn2 bsr wait_pb_down ;wait to push button ldaa ptp anda 0,x staa ptp ;turn off next LED bsr wait_pb_up ;wait to release button inx cpx #$807 bne mn2 ;turn off red, yellow, green bra main ;repeat sequence

More Related