beautypg.com

Sundance SMT326v2 User Manual

Page 14

background image

Release

Page 14 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 Code

Test both a ADC channel and a DAC channel

This first example shows how to test input/output channels. This particular code reads the ADC
channel 1 (IN1) and writes to DAC channel 0 (OUT0)

--------------------------------------------------------------------------------------------------------------------------------------

/* SMT326 test program: Reads the ADC channel 1 (IN1) and writes to DAC channel 0 (OUT0) */

#include
#include
#include

volatile unsigned long *i2c_s1, *i2c_sn;
volatile unsigned long *fpga, *fpgain, *fpgaout, *prog, *status;
volatile int delay,adc_word;
int i,j,t,temp,ctrl_byte,sample, channel, outadd, mask;

main(int argc,char *argv[])
{

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 */
for(i=0;i!=8;i++);
*i2c_sn=0x55; /* set own address = 0x55 */
for(i=0;i!=8;i++);
*i2c_s1=0xa0; /* select register S2 (clock register) */
for(i=0;i!=8;i++);
*i2c_sn=0x1c; /* set clock = 12MHz */
for(i=0;i!=8;i++);
*i2c_s1=0x10; /* select interrupt vector register */

*i2c_s1=0x80;
for(i=0;i!=175;i++);
*i2c_sn=0x55; /* set own address = 0xff */
for(i=0;i!=175;i++);
*i2c_s1=0xa0;
for(i=0;i!=175;i++);
*i2c_sn=0x1c; /* set SCL=90kHz, ext clk=12MHz */
for(i=0;i!=175;i++);
*i2c_s1=0xc1; /* idle / sda,acl high / ack / serial on */
for(i=0;i!=175;i++);