Docstoc

Overview of HCS12 Parallel Ports _1 of 3_.ppt

Document Sample
Overview of HCS12 Parallel Ports _1 of 3_.ppt Powered By Docstoc
					 Overview of HCS12 Parallel Ports (1 of 3)
• The HCS12 members have from 48 to 144 I/O pins
  arranged in 3 to 12 ports and packaged in a quad flat
  pack (QFP) or low profile quad flat pack (LQFP).
• All I/O pins serve multiple functions.
• When a peripheral function is enabled, its associated
  pins cannot be used as I/O pins.
• Each I/O port has several registers to support its
  operation.
• Registers related to I/O ports have been assigned a
  mnemonic name and the user can use these names to
  refer to them:
   movb       #$FF,PORTA        ; output $FF to Port A




                                                          1
   Overview of HCS12 Parallel Ports (2 of 3)
• All I/O ports (except PORTAD0 and PORTAD1) have an
  associated data direction register and a data register.
• The name of the data direction register is formed by adding
  the letters “DDR” as the prefix to the port name. For example,
  DDRA, DDRB, and DDRT.
• To configure a pin for output, write a ‘1’ to the associated bit
  in the data direction register.
• To configure a pin for input, write a ‘0’ to the associated bit in
  the data direction register.

   movb    #$FF,DDRA      ; configure port A for output
   movb    #0,DDRA        ; configure port A for input
   bset    DDRA,%10000001 ; configure Port A pin 7 and 0 for output

                                                                       2
 Overview of HCS12 Parallel Ports (3 of 3)
• The name of the port data register is formed by adding the
  prefix “PORT” to the following ports: A, B, K, E, and AD.
   – PORTA, PORTB, PORTK, PORTE , and PORTAD.
• The name of the port data register is formed by adding the
  prefix “PT” to all the other ports: H, J, M, P, S, and T.
   – PTH, PTJ, PTM, PTP, PTS, and PTT.
• Output a value to a port is done by storing that value to the
  port data register.
       movb      #$FF,DDRH         ; configure Port H for output
       movb      #$37,PTH          ; output the hex value 37 to port H
• Input a value from an input port is done by loading from the
  port data register.
       movb      #0,DDRH           ; configure Port H for input
       ldaa      PTH               ; read data from port H into A
• An I/O port may have up to eight associated registers.
                                                                         3
                   TASK 1
• Blink LED1 and LED2 alternatively on the CSM-
  12C32 board. Call a delay subroutine before
  turning on the next LED.

                  LED2   LED1


                                delay   delay
                         TASK 2
• If both PBMCUSK’s PB1 and PB2 are ON, follow
  sequence 1. Else if PB1 is OFF and PB2 is ON, follow
  sequence 2. Else do nothing.
     LED4   LED3 LED2 LED1          LED4   LED3 LED2 LED1




        SW1 ON, SW2 ON                SW1 OFF, SW2 ON
                            Task 3
• Generate a 0.333 Hz, 66.66% duty cycle,
  square wave on PORTB bit 4 (LED1).

                         2/3             1/3




                     frequency = 0.333 Hz
            Note: Use the oscilloscope to verify frequency and duty cycle.
                                  Task 4
• Consider a two-door sport car with a trunk
  and a glove box. It also includes cabin, trunk,
  and glove box lights.

• Implement the following truth table.
      GBOXD    LEFTD     RGHTD     TRNKD               GBOXL      CBNL      TRNKL

       OPEN      --        --         --                 ON

        --     OPEN        --         --                           ON

        --       --      OPEN         --                           ON

        --       --        --       OPEN                                     ON



              Note: Use the instructions BSET, BCLR, BRSET, and BRCLR as needed.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:1
posted:1/27/2014
language:English
pages:9
pptfiles pptfiles
About