You are currently viewing How to Interface SPI DAC with 8051 Development Board

How to Interface SPI DAC with 8051 Development Board

Spread the love

8051 Development Board

The 8051 Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

DAC (Digital to Analog Converter):

The Microchip Technology Inc. MCP492X are 2.7 – 5.5V, low-power, low DNL, 12-Bit Digital-to-Analog Converters (DACs) with optional 2x buffered output and SPI interface.


☞12-Bit Resolution

☞±0.2 LSB DNL (typ), ±2 LSB INL (typ)

☞Single or Dual Channel

☞SPI™ Interface with 20 MHz Clock Support

☞Simultaneous Latching of the Dual DACs w/LDAC

☞Fast Settling Time of 4.5 μs

☞Selectable Unity or 2x Gain Output

☞450 kHz Multiplier Mode

☞External VREF Input

☞Extended Temperature Range: -40°C to +125°C

Pin Assignment with 8051

Circuit Diagram to interface SPI DAC with 8051

Source Code

The Interfacing SPI ADC with 8051 program is very simple and straight forward, that uses a delay procedure loop based software delay. In C programs you cannot be sure of delay, because it depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to SPI DAC using 8051


Title : Program to display waveform



sbit CS =P3^5;

//chisp select port pin P3.5 sbit SCK=P3^6;

//SCK Port pin P3.6 sbit SDI=P3^7;

//SDI port pin P3.7 void SPI_out(unsigned char);

unsigned char x=0x80,i;


// Main program Starts


void main()


unsigned int Data=0x37FF;

//Assing Data Here e.g 0x33ff, 0x37ff, 0x3fff unsigned char data1;

SCK = 0;

//sck pull to low while(1)

//loop forever




//make cs to low data1=(Data>>8);

//shift and send to spiout SPI_out(data1);

//send high byte data1=Data; SPI_out(data1);

//send low byte CS=1;

if (Data == 0) Data = 0x77FF;

//make cs to high




// SPI Data out routine


void SPI_out(unsigned char Data_val)




SDI=(Data_val & x)?1:0;


//make sck high Data_val=Data_val<<1;


//make sck low



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.