Sundance SMT326v2 User Manual
Page 20
Release
Page 20 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
*i2c_sn=0x55; /* set own address = 0xff */
for(i=0;i!=1000;i++);
printf("wi2c_sn=%x\n",*i2c_sn);
*i2c_s1=0xa0;
for(i=0;i!=1000;i++);
printf("ei2c_s1=%x\n",*i2c_s1);
*i2c_sn=0x1c; /* set SCL=90kHz, ext clk=12MHz */
for(i=0;i!=1000;i++);
printf("ri2c_sn=%x\n",*i2c_sn);
*i2c_s1=0xc1; /* idle / sda,acl high / ack / serial on */
for(i=0;i!=1000;i++);
printf("ti2c_s1=%x\n",*i2c_s1);
while(((temp=(*i2c_s1)&0x01))==0) {
for(i=0;i!=1000;i++);
}
fpga+=32; /* point to control register */
for(channel=0;channel!=8;channel++) {
*fpga=0x85+(channel<<4);
printf("ch %d\n",channel);
for(delay=0;delay!=100000;delay++);
printf("1\n");
i2c_send_address(0x20,0);
i2c_write(1);
i2c_write(0x00);
i2c_stop();
i2c_send_address(0x20,0);
i2c_write(2);
i2c_write(0x00);
i2c_stop();
i2c_send_address(0x20,0);
i2c_write(3);
i2c_write( 00);
i2c_stop();
i2c_send_address(0x20,0);
i2c_write(4);
i2c_write( 00);
i2c_stop();
ctrl_byte=9;
i2c_send_address(0x20,0);
i2c_write(5);
i2c_write(ctrl_byte);
i2c_stop();
i2c_send_address(0x20,0);
i2c_write(0x80);
i2c_restart(0x21,0);
temp=*i2c_sn; /* discard 1st byte */
temp=i2c_read(1);
for(delay=0;delay!=100000;delay++);