//********************************************************************
//
// Author : ADI - Apps www.analog.com/MicroConverter
//
// Date : 16 October 2003
//
// File : DACsine.c
//
// Hardware : ADuC845
//
// Description : DAC outputs a sine wave of about 400Hz.
//
//
//********************************************************************
#include <stdio.h>
#include <ADuC845.h>
sbit LED = 0x0B4;
void main (void)
{
unsigned code values[64][2]={{0x07, 0xFF},{0x08, 0xC8},{0x09, 0x8E},{0x0A, 0x51},{0x0B, 0x0F},
{0x0B, 0xC4},{0x0C, 0x71},{0x0D, 0x12},{0x0D, 0xA7},{0x0E, 0x2E},
{0x0E, 0xA5},{0x0F, 0x0D},{0x0F, 0x63},{0x0F, 0xA6},{0x0F, 0xD7},
{0x0F, 0xF5},{0x0F, 0xFF},{0x0F, 0xF5},{0x0F, 0xD7},{0x0F, 0xA6},
{0x0F, 0x63},{0x0F, 0x0D},{0x0E, 0xA5},{0x0E, 0x2E},{0x0D, 0xA7},
{0x0D, 0x12},{0x0C, 0x71},{0x0B, 0xC4},{0x0B, 0x0F},{0x0A, 0x51},
{0x09, 0x8E},{0x08, 0xC8},{0x07, 0xFF},{0x07, 0x36},{0x06, 0x70},
{0x05, 0xAD},{0x04, 0xEF},{0x04, 0x3A},{0x03, 0x8D},{0x02, 0xEC},
{0x02, 0x57},{0x01, 0xD0},{0x01, 0x59},{0x00, 0xF1},{0x00, 0x9B},
{0x00, 0x58},{0x00, 0x27},{0x00, 0x09},{0x00, 0x00},{0x00, 0x09},
{0x00, 0x27},{0x00, 0x58},{0x00, 0x9B},{0x00, 0xF1},{0x01, 0x59},
{0x01, 0xD0},{0x02, 0x57},{0x02, 0xEC},{0x03, 0x8D},{0x04, 0x3A},
{0x04, 0xEF},{0x05, 0xAD},{0x06, 0x70},{0x07, 0x36}};
PLLCON = 0x03;
DACCON = 0x03; //DAC to pin 14, 12bit, 2.5v range, normal, Power on
DACH = 0x08;
DACL = 0x00;
while (1)
{
int i;
for ( i = 0 ; i < 64; i++)
{
DACH = values[i][0];
DACL = values[i][1];
}
LED ^= 1;
}
}