Specifications
Program Examples
B-17
Program Examples
;=========================================================================
* File name : GPIO_OUT.asm
* Description : PROGRAM TO CHECK THE GPIO PINS OF 240x as outputs *
* This program writes a running pattern of 0’s to the GPIO pins of 240x *
* It ouputs a total of 8 bit patterns to the five GPIO ports (A,B,C,E,F) *
* Each bit pattern forces a particular bit low and forces the other 7 *
* bits high. This goes on in an endless loop. *
;=========================================================================
.title ” 240x GPIO”
.data ; Loaded @ 300h in data memory
b0 .word 0FFFEh ; Turn–on GPIO0
b1 .word 0FFFDh ; Turn–on GPIO1
b2 .word 0FFFBh ; Turn–on GPIO2
b3 .word 0FFF7h ; Turn–on GPIO3
b4 .word 0FFEFh ; Turn–on GPIO4
b5 .word 0FFDFh ; Turn–on GPIO5
b6 .word 0FFBFh ; Turn–on GPIO6
b7 .word 0FF7Fh ; Turn–on GPIO7
GPR0 .word 0 ; 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 #0000h,SCSR1
SPLK #006Fh, WDCR ; Disable WD
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 #0FFFFh, PADATDIR ; All pins are o/p’s










