Specifications

Program Examples
B-15
Program Examples
;============================================================================*
* File name : ADC.asm *
* Description : PROGRAM TO INITIALIZE THE ADC MODULE OF 240x *
* This program initializes the ADC module of the ’240x and does a conversion *
* of all the analog input channels. The results of the conversion are *
* available in the RESULTSn register, which can be accessed by the user *
* application. The ADC operates as one 16–state sequencer & the conversions *
* are stopped once the sequencer reaches EOS (End of sequence) *
;============================================================================*
.title ”ADC”
.bss GPR0,1 ; General purpose register
.include 240x.h
.copy ”vector.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
CLRC SXM
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 #0080h,SCSR1 ; Enable clock to ADC module
KICK_DOG
SPLK #0h,GPR0 ; Set wait state generator for:
OUT GPR0,WSGR ; Program Space, 0–7 wait states
* Initialize ADC registers
LDP #0E1h
SPLK #0100000000000000b,ADCTRL1 ; Reset ADC module
SPLK #0011000000010000b,ADCTRL1 ; Take ADC out of reset
; ||||||||||||||||
; 5432109876543210
; 15 – RSVD | 14 – Reset(1) | 13,12 – Soft & Free
; 11,10,9,8 – Acq.prescalers | 7 – Clock prescaler
; 6 – Cont.run (1) | 5 – Int.priority (Hi.0)
; 4 – Seq.casc (0–dual)