You are on page 1of 3

Ramp generation

; this is a assembly program that outputs a ramp to the D to A Converter


area ponn, CODE, READONLY
; pin select registers
PINSEL0 EQU 0XE002C000
PINSEL1 EQU 0XE002C004
PINSEL2 EQU 0XE002C014
; D to A Converter
DACR EQU 0XE006C000

EXPORT __main
ENTRY
__main
ldr R3, =0x000003FF ; constant for compare operation
ldr R1, =PINSEL1 ; Address of PINSEL1
ldr R2, =0x00080000 ;
str R2, [R1] ;
ldr R0, =DACR ; DACR Register
ldr R2, =0x0;
DtoA
lsl R1, R2, #6 ; shift R2 left 6 places and put in R1
str R1, [R0] ; Output to D to A
add R2, R2, #1 ; increment R2
cmp R2, R3 ; Check if too big

BLT DtoA ; if not branch back


ldr R2, =0x0 ; if no reset R2 to 0

B DtoA ;

END

Triangular waveform generation:


; this is a assembly program that outputs a triangular wave to the D to A Converter
area ponn, CODE, READONLY
; pin select registers
PINSEL0 EQU 0XE002C000
PINSEL1 EQU 0XE002C004
PINSEL2 EQU 0XE002C014
; D to A Converter
DACR EQU 0XE006C000

EXPORT __main
ENTRY
__main
ldr R3, =0x000003FF ; constant for compare operation
ldr R1, =PINSEL1 ; Address of PINSEL1
ldr R2, =0x00080000 ;
str R2, [R1] ;
ldr R0, =DACR ; DACR Register
ldr R2, =0x0;
DtoAp
lsl R1, R2, #6 ; shift R2 left 6 places and put in R1
str R1, [R0] ; Output to D to A
add R2, R2, #1 ; increment R2
cmp R2, R3 ; Check if too big

BLT DtoAp ; if not branch back


DtoAn
lsl R1, R2, #6 ; shift R2 left 6 places and put in R1
str R1, [R0] ; Output to D to A
subs R2, R2, #1 ; decrement R2

BNE DtoAn ; if R2 has not gone to zero branch back


B DtoAp ;

END

You might also like