大家好,看看我写的模拟spi程序有问题吗?
因为我用自身的spi给ade7758写控制字写不进去,我用示波器观察DIN,DOUT,SCLK引脚就SCLK有波形,所以我该为模拟spi,请大家看下有问题吗?
static bit ESCK7758 @ PORTCIT(PORTC,3);
static bit EDOUT7758 @ PORTCIT(PORTC,4);
void write7758(uchar addr,uchar length)
{
uchar i;
dint();
CS7758 = 0;
addr |= 0x80; //writeflag
SSPBUF = addr;
/*
while(!SSPIF);
SSPIF = 0;
*/
for(i=0;i<8;i++)
{
delay(1);
PORTC |= ESCK7758;
delay(1);
if(addr & 0x80)
{
PORTC |= EDOUT7758;
}
else
{
PORTC &= ~EDOUT7758;
}
addr = addr<<1;
delay(1);
PORTCT &= ~ESCK7758;
}
} |