You have no items in your shopping cart.

Subtotal: 0.00

How to Interface SPI DAC with 8051 Development Board

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.

Features

  • 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

 

SPI - DAC

8051 Lines

SPI - DAC

MCP 2491

CS

P3.5





CLK

P3.6

MOSI

P3.7

Note: Measure DAC output at J2 PTB connector.

 

Circuit Diagram to 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

***************************************************************************************

#include

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

{

CS=0;

Data--;

//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)

{

for(i=0;i<8;i++)

{

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

SCK=1;

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

SCK=0;

//make sck low

}

}