本帖最后由 sodapop 于 2013-3-29 15:34 编辑
利用STM32的串行总线SPI控制AD5292时,发送控制数据以及从AD5292的RDAC寄存器读写数据时,程序应该怎样实现?
SPI的MISO,MOSI,CLK以及NSS分别与AD5292的SDO,DIN,CLK,SYNC连接,设置SPI主模式,使能nss软件模式,并使能输出,配置相应的GPIO管脚控制SYNC
void SPI1_Configuration()
{
SPI_InitTypeDef SPI_InitStructure;
SPI_InitStructure.SPI_Direction =SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
/* Enable SPI_MASTER NSS output for master mode */
SPI_SSOutputCmd(SPI1, ENABLE);
/* Enable SPI1 */
SPI_Cmd(SPI1, ENABLE);
}
|