在线时间0 小时
UID89343
ST金币0
蝴蝶豆0
注册时间2008-8-17
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
哪位用STM32F103控制过AD7792,NSS、SCK、MOSI上都有波形,MISO上就是没数!
/* SPI1 Master */
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_Cmd(SPI1, ENABLE);
GPIO_SetBits(GPIOA, GPIO_Pin_4);
Delay(500);//90uS
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
// Wait for SPI1 Tx buffer empty
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
// Send SPI1 ReadId for read AD7792 ID register
SPI_I2S_SendData(SPI1,ReadID);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
SPI_I2S_SendData(SPI1, 0xA5);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
SPI1_Rx = SPI_I2S_ReceiveData(SPI1);
GPIO_SetBits(GPIOA, GPIO_Pin_4);
高人指点指点! |
|