使用STM32的spi与AFE4400通信,每写入或读取一个数据都需要等待几百微秒后才能继续操作,否则读取的数据都是0,有什么地方设置不正确吗,请大神指点
Amy Luo:
您好,您用示波器测量一下ADC_RDY pin(28pin)波形周期频率是多少
user2002705:
回复 Amy Luo:
您好,不仅仅是读取有问题,初始化AFE4400的时候,每写入一个字节都得延时约1ms,否则初始化失败,下面设置函数
static void AFE4400_Set_Register(SPI_TypeDef *pSPI, unsigned char reg_address, unsigned int data){ unsigned short i = 0,j = 35000; AFE_CS_L; for(i = 0; i < j; i++){} SPI_I2S_SendData(pSPI,reg_address); //写入寄存器地址 #if USE_DELAY for(i = 0; i < j_delay; i++){} #else while(SPI_I2S_GetFlagStatus(pSPI, SPI_I2S_FLAG_BSY) == RESET) #endif SPI_I2S_SendData(pSPI, (data>>16)&0xFF); #if USE_DELAY for(i = 0; i < j_delay; i++){} #else while(SPI_I2S_GetFlagStatus(pSPI, SPI_I2S_FLAG_BSY) == RESET) #endif SPI_I2S_SendData(pSPI,(data>>8)&0xFF); #if USE_DELAY for(i = 0; i < j_delay; i++){} #else while(SPI_I2S_GetFlagStatus(pSPI, SPI_I2S_FLAG_BSY) == RESET) #endif SPI_I2S_SendData(pSPI,(data)&0xFF); for(i = 0; i < j; i++){} AFE_CS_H;
}