KEMBAR78
DAC Waveform Generation Guide | PDF | Digital To Analog Converter | Telecommunications Engineering
0% found this document useful (0 votes)
79 views5 pages

DAC Waveform Generation Guide

The document describes assembly programs to generate different waveforms using the on-chip digital to analog converter (DAC) of a microcontroller. It includes programs to generate square, sawtooth, triangular, and sine waves. For each waveform type, it provides the concept, a diagram showing the shape of the waveform, and the assembly code program to generate that waveform using the DAC. It initializes the DAC control register and pin mux, then uses loops to output binary values corresponding to voltage levels over time to shape the waveform.

Uploaded by

Sathvik S Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views5 pages

DAC Waveform Generation Guide

The document describes assembly programs to generate different waveforms using the on-chip digital to analog converter (DAC) of a microcontroller. It includes programs to generate square, sawtooth, triangular, and sine waves. For each waveform type, it provides the concept, a diagram showing the shape of the waveform, and the assembly code program to generate that waveform using the DAC. It initializes the DAC control register and pin mux, then uses loops to output binary values corresponding to voltage levels over time to shape the waveform.

Uploaded by

Sathvik S Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab-8

Digital to Analog Converter

AIM: To use the on chip DAC to generate different waveforms.

Description:
Basic Operation of a DAC is to take a 10 bit binary value into analog voltage Aout which is
proportional to the reference voltage VREF.
where VREF=3.3V

Aout
DAC (P0.25)

0XE006C000 DACR

Once Aout is enabled, conversion can be started by writing into the value in the control
register (15:6)

Ex: 8.1
Write an assembly program to generate a Square Wave.

3.3V

tp

Hint:
Send a binary value, corresponding to each voltage level and then call a delay corresponding
to tp/2.

Program:
AREA SQUARE,CODE,READONLY
EXPORT __main
PINSEL1 EQU 0XE002C004
DACR EQU 0XE006C000
__main

LDR R3,=0X000003FF
LDR R1,=PINSEL1
LDR R2,=0X00080000
STR R2,[R1]
LDR R0,=DACR

DTOAP LDR R1,=0XFFFF


STR R1,[R0]
LDR R4,=0XFFFF
DELAY SUBS R4,R4,#1
BNE DELAY
LDR R1,=0X0
STR R1,[R0]
LDR R4,=0XFFFF
DELAY1 SUBS R4,R4,#1
BNE DELAY1
LDR R2,=0X0
B DTOAP

END

Ex: 8.2
Write an assembly program to generate a Saw Tooth Waveform. Check the program for
different step values and observe the waveform.

2V

0
0 Tp 2Tp

Hint:
∆ = Step Value
N = Total number of Steps =
Step Delay = Tp/N
Step1- Load the binary value corresponding to 2V
Step2- Increment/Decrement the binary value in steps of ∆.
Step3- Call the Step Delay.
Step4- Repeat this till the voltage level is reached.
Step5- Repeat Step1.

Program:

AREA SAWTOOTH,CODE,READONLY
EXPORT __main
PINSEL1 EQU 0XE002C004
DACR EQU 0XE006C000
__main
LDR R3,=0X000003FF
LDR R1,=PINSEL1
LDR R2,=0X00080000
STR R2,[R1]
LDR R0,=DACR
LDR R2,=0X0
DTOA LSL R1,R2,#6
STR R1,[R0]
SUBS R2,R2,#1
BNE DTOA
LDR R2,=0X0
B DTOA
END
Ex: 8.3
Write the assembly program to generate Triangular Waveform

3.0 V

0
Tp
2Tp

Program:
AREA TRIANGULAR,CODE,READONLY
EXPORT __main
PINSEL1 EQU 0XE002C004
DACR EQU 0XE006C000
__main
LDR R3,=0X000003FF
LDR R1,=PINSEL1
LDR R2,=0X00080000
STR R2,[R1]
LDR R0,=DACR
LDR R2,=0X0
DTOAP LSL R1,R2,#6
STR R1,[R0]
ADD R2,R2,#1
CMP R2,R3
BLT DTOAP
DTOAN LSL R1,R2,#6
STR R1,[R0]
SUBS R2,R2,#1
BNE DTOAN
B DTOAP
END

Ex: 8.4
Write an assembly program to generate a Sine Wave

3.3 V

Vout = 512+512Sin(Ө)
Program:
AREA SINE,CODE,READONLY
EXPORT __main
PINSEL1 EQU 0XE002C004
DACR EQU 0XE006C000
__main

LDR R1,=PINSEL1
LDR R2,=0X00080000;
STR R2,[R1];
LDR R0,=DACR
L1 LDR R3,=0X0C
LDR R4,=SINDATA
L2 LDR R2,[R4]
LSL R1,R2,#6
STR R1,[R0]
ADD R4,#0X04
SUBS R3,R3,#1
BNE L2
B L1
ALIGN
SINDATA DCD 0X01FF,0X02FE,0X03BA,0X03FF
DCD 0X03DA,0X02FE,0X01FF,0X0100
DCD 0X0044,0X0,0X0044,0X0100
END

You might also like