void Write_Spi_9Bit1( uint8_t Bit_A0, uint8_t DatByte )
{
uint8_t i;
DP2_CS = 0;
DP2_SCK = 0;//SCK 产生下降沿
if( Bit_A0 ) { DP2_SI = 1;} //=0: Write Wiper Register A =1: Write Wiper Register B
else { DP2_SI = 0; }
delay_us( 5 );
DP2_SCK = 1;
for(i =0;i<8; i++)
{
DP2_SCK = 0;
DP2_SI = ( DatByte>>(7-i) )&0x01; //bit7 first
//delay_us( 2 );
DP2_SCK = 1;
}
DP2_CS = 1;
} 数字电位器驱动程序,MAX5386 9位SPI写数据,一直不成功,哪位高手能不能指点下。谢谢了
|