Analog Devices 16Bit ADC AD7606 테스트
AD7606 핀맵 정의
//------------------------------------------------------------------------------
//ADC AD7606 Driver
#define AD7606_CS_HI() (LATD |= BIT0)
#define AD7606_CS_LO() (LATD &= ~BIT0)
#define AD7606_RST_HI() (LATD |= BIT1)
#define AD7606_RST_LO() (LATD &= ~BIT1)
#define AD7606_START_HI() (LATD |= BIT2)
#define AD7606_START_LO() (LATD &= ~BIT2)
#define AD7606_CS_INIT() (TRISD &= ~BIT0)
#define AD7606_RST_INIT() (TRISD &= ~BIT1)
#define AD7606_START_INIT() (TRISD &= ~BIT2)
#define AD7606_SPI_INIT SPI1_Init
//------------------------------------------------------------------------------
AD7606 Data Read 코드
void AD7606_ReadBuf(short *pBuff)
{
AD7606_START_LO();
Delay_Us(10);
AD7606_START_HI();
AD7606_CS_LO();
pBuff[0] = SPI1_WriteReadByte(0);
pBuff[0] |= SPI1_WriteReadByte(0)<<8;
pBuff[1] = SPI1_WriteReadByte(0);
pBuff[1] |= SPI1_WriteReadByte(0)<<8;
pBuff[2] = SPI1_WriteReadByte(0);
pBuff[2] |= SPI1_WriteReadByte(0)<<8;
pBuff[3] = SPI1_WriteReadByte(0);
pBuff[3] |= SPI1_WriteReadByte(0)<<8;
//-----------------------------------------
pBuff[4] = SPI1_WriteReadByte(0);
pBuff[4] |= SPI1_WriteReadByte(0)<<8;
pBuff[5] = SPI1_WriteReadByte(0);
pBuff[5] |= SPI1_WriteReadByte(0)<<8;
pBuff[6] = SPI1_WriteReadByte(0);
pBuff[6] |= SPI1_WriteReadByte(0)<<8;
pBuff[7] = SPI1_WriteReadByte(0);
pBuff[7] |= SPI1_WriteReadByte(0)<<8;
AD7606_CS_HI();
}