Specifications

Program Examples
B-11
Program Examples
;=================================================================================
* File Name: SPI.asm
* Description: PROGRAM TO OUTPUT SERIAL DATA THROUGH THE SPI PORT
* This program outputs a set of incrementing words (that roll over) through
* the SPI. If a Digital–to–analog (DAC) converter is connected to the SPI,
* the DAC outputs a sawtooth waveform. The program sends data to the serial DAC
* by means of the SPI. For this example, the TLC5618 serial DAC from TI was used.
;=================================================================================
.include 240x.h
.include vector.h
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; Variable Declarations for on chip RAM Blocks
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
.bss GPR0,1 ;General purpose registers.
.bss GPR3,1
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; M A C R O – Definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
KICK_DOG .macro ;Watchdog reset macro
LDP #00E0h
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h
.endm
;===========================================================================
; M A I N C O D E – starts here
;===========================================================================
.text
START: LDP #0
SETC INTM ;Disable interrupts during initialization.
SPLK #0h,GPR3
OUT GPR3,WSGR ;Set XMIF to run with no wait states.
CLRC SXM ;Clear Sign Extension Mode
CLRC OVM ;Reset Overflow Mode
CLRC CNF ;Config Block B0 to Data mem.
LDP #WDCR>>7
SPLK #006Fh,WDCR ;Disable WD
KICK_DOG
LDP #SCSR1>>7 ;Set PLL for x4 mode
SPLK #0020h,SCSR1 ;Enable clock to SPI module