84PCE:Ports:A000

From WikiTI
Revision as of 19:09, 1 April 2015 by MateoConLechuga (Talk | contribs)

Jump to: navigation, search

Synopsis

Port Number: A000-?

Memory-mapped address: F50000-?

Function: Keypad Controller options

Using the keypad

  • This is the layout of what the keypad looks like according to the controller:
Address Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 Bit 8 Bit 9 Bit 10
F50010
F50012 graph trace zoom wind y= 2nd mode del
F50014 on sto ln log x^2 x^-1 math alpha
F50016 0 1 4 7 , sin apps X
F50018 . 2 5 8 ( cos prgm stat
F5001A (-) 3 6 9 ) tan vars
F5001C enter + - * / ^ clear
F5001E down left right up

The controller works by scanning lines; not by selecting a row and column like previous versions.

For example, if you set the controller to scan 3 lines, it will affect only the data in F00010h, F00012h, F00014h, and leave the others alone.

You will want to disable interrupts when reading, as OS interrupts can cause garbage to be read.

Before you exit your program, if you have modified the keypad controller in any way, it is crucial to restore the keypad controller back to its original state.

This is how TI does it (Not really; ports are used instead, but it's the same idea)

RestoreKeyboard:
 ld bc,0F50000h
 xor a		; Mode 0
 ld (bc),a
 inc c		; 0F50001h
 ld a,15	; Wait 15 APB cycles before scanning each row
 ld (bc),a
 inc c		; 0F50002h
 xor a
 ld (bc),a
 inc c		; 0F50003h
 ld a,15	; Wait 15 APB cycles before each scan
 ld (bc),a
 inc c		; 0F50004h
 ld a,8		; Number of rows to scan
 ld (bc),a
 inc c		; 0F50005h
 ld (bc),a	; Number of columns to scan
 ret

Controller Address Uses:

  • F50000 (R/W):
    • Bits 0-1: Scan mode
      • Mode 0: Idle.
      • Mode 1: Indiscriminate key detection. Data registers are not updated, but whenever any key is pressed, interrupt bit 2 is set (and cannot be cleared until the key is released).
      • Mode 2: Single scan. The keypad is scanned once, and then the mode returns to 0.
      • Mode 3: Continuous scan. When scanning completes, it just starts over again after a delay.
    • Bits 2-15: Number of APB cycles to wait before scanning each row
    • Bits 16-31: Number of APB cycles to wait between scans
  • F50004 (R/W):
    • Bits 0-7: Number of rows to read (later rows are not updated in F50010-F5002F, and just read as whatever they were before being disabled)
    • Bits 8-15: Number of columns to read (later column bits in a row are set to 1 when it is updated)
  • F50008 (R/W): Keypad interrupt status/acknowledge (3-bit). Write "1" bits to acknowledge.
    • Bit 0: Keypad scan complete
    • Bit 1: Keypad data register changed
    • Bit 2: Key pressed in mode 1
  • F5000C (R/W): Keypad interrupt mask (3-bit). Set each bit to 1 if the corresponding event in [F50008] should cause an interrupt.
  • F50010-F5002F (R): Keypad data, one halfword per row.
  • F50030-F5003F (R/W): Keypad GPIOs. Each register is 20 bits, with one bit per GPIO. The role of each register is unknown.

NOTE: The CE appears to use the same keypad controller as the nSpire CX.