Test a dac channel – Sundance SMT326v2 User Manual
Page 19
Release
Page 19 of 24
SMT326 DSP PC/ISA System User Guide
Document Name:
SMT326 Ugv2.doc
Original Date: 08/11/97
Product Name:
SMT326
Revision Date: 08/26/99
Author:
Graeme Parker – Fabio Ancona
Test a DAC channel
This second example shows how to test a DAC channel. The program generates a sine wave that it
will be the digital input to the DAC to test.
/* SMT326 DAC channel 0 test program */
#include
#include
#include
volatile unsigned long *i2c_s1, *i2c_sn;
volatile unsigned long *fpga, *prog, *status;
volatile int delay;
int i,j,t,temp,ctrl_byte, channel, mask;
char ch;
int sin_table[256];
int f1,f2,f3,f4;
int i1,i2,i3,i4;
main(int argc,char *argv[])
{
for(i=0;i!=256;i++) sin_table[i]=(int)(000+256*(sin(3.14*i/128)));
prog =(unsigned long *)0x80300000;
fpga =(unsigned long *)0x80200000;
i2c_s1=(unsigned long *)0x80100001;
i2c_sn=(unsigned long *)0x80100000;
/* Setup the I2C interface device */
printf("Setting up I2C interface\n");
*i2c_s1=0x80; /* select own address regsiter */
printf("ai2c_s1=%x\n",*i2c_s1);
for(i=0;i!=8;i++);
printf("ai2c_s1=%x\n",*i2c_s1);
*i2c_sn=0x55; /* set own address = 0x55 */
for(i=0;i!=8;i++);
printf("si2c_sn1=%x\n",*i2c_sn);
*i2c_s1=0xa0; /* select register S2 (clock register) */
printf("di2c_s1=%x\n",*i2c_s1);
for(i=0;i!=8;i++);
printf("di2c_s1=%x\n",*i2c_s1);
*i2c_sn=0x1c; /* set clock = 12MHz */
for(i=0;i!=8;i++);
printf("fi2c_sn=%x\n",*i2c_sn);
*i2c_s1=0x10; /* select interrupt vector register */
printf("mi2c_s1=%x\n",*i2c_s1);
*i2c_s1=0x80;
printf("qi2c_s1=%x\n",*i2c_s1);
for(i=0;i!=1000;i++);
printf("qi2c_s1=%x\n",*i2c_s1);