有人用过AD5724R或者AD57xx系列芯片吗。。
附上程序。哪位知道的给看看
#include "config.h" //0.4/0.5/0.6/0.7 分别是lpc2132的spi口的sck0,mosi,miso,ssel0,
#define slave_cs (1<<7)
void delayNs(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
void SPI_init(void)
{
PINSEL0=(PINSEL0&(0Xffff00ff))|(0X54<<8);
SPCCR = 0X52;
SPCR = (0<<3)|
(1<<4)|
(1<<5)|
(0<<6)|
(0<<7);
}
//uint8 const table[] = { 0x01,0xfe,0xa4,0xb0,0x99,0x92,0x82,0xf8,
//0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void SPI_SendData (uint32 data)
{
IO0SET = slave_cs;
IO0CLR = slave_cs;
delayNs(100);
IO0SET = slave_cs;
SPI_SPDR = data;
while (0==(SPI_SPSR & 0X80));
delayNs(100);
IO0CLR = slave_cs;
delayNs(100);
}
void ad_init()
{
SPI_SendData(0x880000);
SPI_SendData(0X100011);
}
int main (void)
{
PINSEL0 = 0;
IO0DIR = slave_cs;
SPI_init();
ad_init();
SPI_SendData(0x00ef00);
// SPI_SendData(0x1d0000);
// while(1);
return 0;
}