RANDOM PAGE
SITE SEARCH
LOG
IN
SIGN UP
HELP
To gain access to revision questions, please sign up and log in.
A2
Tristate Input Output Ports
PORTA, PORTB and PORTC
- The AQA processor has three input / output ports called PORTA, PORTB and PORTC.
- They are eight bit ports.
- The port pins can be configured to be inputs or outputs.
- Tristate logic is used to achieve this.
TRISA, TRISB and TRISC
- Three data direction registers called TRISA, TRISB and TRISC are used to control the I/O pins on the three I/O data ports.
- Binary data in the TRIS registers controls the direction of the PORT registers.
- 1 = I = Input.
- 0 = O = Output. This is logical and easy to remember.
Data I/O Example
CTRL+Click here to run the simulator.
- Type in the code below or copy and paste it.
- Click the "A" button to assemble the code (translate it into binary).
- Click the "S" button to step through the program.
Send data to four of the eight LEDs. Click (red highlight) to connect the LEDs to PORTA.
INIT:
MOVW 0xF0 ; IIIIOOOO
MOVWR TRISA ; PORTA has four
; inputs and four
; outputs
LOOP:
MOVW 0xAA ; 10101010 test data
MOVWR PORTA ; Write data to PORTA
MOVW 0x55 ; 01010101 test data
MOVWR PORTA ; Write data to PORTA
JMP LOOP
- The program sends test data to PORTA.
- The test data is 0x55 = 01010101 and 0xAA = 10101010
- Since only four bits are set as outputs, the data that reaches the ports is
0x05 = 00000101 and 0x0A = 00001010
- Four of the LEDs should flash in this alternating pattern.
reviseOmatic V3
Contacts, ©, Cookies, Data Protection and Disclaimers
Hosted at linode.com, London