ECET340 Notes

ECET340 Notes - E CET340 Notes Parallel Input/Output Ports...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ECET340 Notes Parallel Input/Output Ports Ports are nothing more than electronic connections between the Microprocessor (MPU) and the outside world. Ports are end points of connection between the MPU and the outside world. There are two types of ports, serial and parallel. Serial Port: They only allow information be transferred one bit at a time. They are better for long distances because they are more consistent and efficient. Parallel Port: They allow information to be transferred a few bits at a time. They are faster in short distances and more efficient when transferring information over short distances. Parallel ports are much faster, but they are also expensive for longer lengths. They can also act as an antenna for nearby ports (inference) if they are the right length. HCS12 Parallel ports The HCS12 has a few parallel ports that can exchange data in chunks of 8- bits or less. The parallel ports of the HCS12 are named: A, B, . ..., H. Parallel Output Port If a MPU connects with a parallel port to an external device, and the MPU “wants” to output data to that device, there would always be a speed mismatch between the two devices, the MPU being much faster then the device. The solution to the speed mismatch is to latch the data coming out of the parallel ports. Parallel Input Port:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bus Contention: When one bus line is trying to drive one output while the other bus line is trying to output another number. A tri- state buffer is needed to be used in order to connect two or more devices to the MPU. If they are not connected to a buffer, than the devices will short causing the circuit to fry. The HCS12 has several parallel ports that are almost all 8-bits. The HCS12 parallel ports are bidirectional. A port is considered to be bidirectional if it can be configured as an input port or as an output port. How do we configure the direction of a given parallel port? Each parallel port has a direction register associated with it. The purpose of this register is to set the pins of the parallel port as output or input. Output Port Assembly Code LDAA #%1111 1111 ; (A) = %1111 1111 STAA $0003 Input Port Assembly Code LDAA #%0000 0000 STAA $0003 Ex. A.) Write code to configure all pins of Port B as output pins . Assembly LDAA #$FF STAA $FF
Background image of page 2
CHAR * myDDRB ; myDDRB = (CHAR * ) 0x0003 ; ( * myDDRB ) = 0xFF ; or #DEFINE myDDRB * (CHAR * ) (0x003) Header File myDDRB = 0xFF ; B.) Write code to configure all pins of Port B as output pins; and send the hexadecimal value 55 through those. LDAA #$FF STAA $0003 LDAA #$55 STAA #$0001 #DEFINE DDRB * ( VOLATILE UNSIGNED CHAR * ) (0x0003) #DEFINE PORT * ( VOLATILE UNSIGNED CHAR * ) (0x0001) DDRB = 0xFF; PORTB = 0x55 C.) Write code that. .. --> Configure pins of Port B as input
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 04/19/2011.

Page1 / 19

ECET340 Notes - E CET340 Notes Parallel Input/Output Ports...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online