Specifications

Program Examples
B-19
Program Examples
;=========================================================================
* File name : GPIO_IN.asm *
* Description : PROGRAM TO CHECK GPIO PINS OF 240x as inputs *
* All GPIO bits are programmed as inputs and the values read from the *
* GPIO pins are written in 60h,61h,62h,63h,64h of Data memory *
;=========================================================================
.title ” 240x GPIO”
.bss GPR0,1 ; Gen purp reg
.include 240x.h
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; M A C R O – Definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
KICK_DOG .macro ; Watchdog reset macro
LDP #00E0h ; DP––>7000h–707Fh
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h ; DP––>0000h–007Fh
.endm
.text
START: LDP #0h ; Set DP=0
SETC INTM ; Disable interrupts
SETC CNF
SPLK #0000h,IMR ; Mask all core interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
LDP #00E0h ; (E0=224)(E0*80=7000)
SPLK #006Fh, WDCR ; Disable WD
SPLK #0,SCSR1 ; Put PLL in x4 mode.
KICK_DOG
SPLK #0h,GPR0 ; Set wait state generator for
OUT GPR0,WSGR ; external address space.
LDP #00E1h
SPLK #00000h,MCRA ; Select IOPAn & IOPBn as GPIO pins
SPLK #0FF00h,MCRB ; Select IOPCn as GPIO pins
SPLK #00000h,MCRC ; Select IOPEn & IOPFn as GPIO pins
SPLK #0h, PADATDIR ; All GPIO pins are programmed
SPLK #0h, PBDATDIR ; as inputs
SPLK #0h, PCDATDIR
SPLK #0h, PEDATDIR
SPLK #0h, PFDATDIR
MAIN LDP #0 ; This loop reads the level on
LAR AR0,#60h ; the GPIO pins. The bit patterns
MAR *,AR0 ; read from the 5 GPIO ports
LDP #00E1h ; is copied in the data memory
LACL PADATDIR
SACL *+