2019-07-14 18:32发布
wang222221 发表于 2018-8-16 07:39 是不是太快了?示波器检查一下 SCLK 频率,然后对照一下 ADC 芯片手册上记载的最大频率。另外,这么快的信号要注意射频传输线效应。
htxk 发表于 2018-8-16 07:44 1. 不会快的,SPI的还能支持更高的通信速度,理论上DMA存取数据到缓存数组中也应该能跟得上吧(此处不敢确定);2. AD支持的最大SCLK=80MHz; 3. sclk的图像如下所示;
最多设置5个标签!
//SPI3
void SPIx_Init(void)
{
SPI_InitTypeDef SPI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(AD_SPI_SCK_GPIO_CLK|AD_SPI_MISO_GPIO_CLK|AD_SPI_MOSI_GPIO_CLK|AD_CS_GPIO_CLK, ENABLE);
AD_SPI_CLK_INIT(AD_SPI_CLK,ENABLE); //SPIʱÖÓʹÄÜ
GPIO_PinAFConfig(AD_SPI_SCK_GPIO_PORT,AD_SPI_SCK_PINSOURCE,AD_SPI_SCK_AF); //PC10¸´ÓÃSPI3µÄSCLK
GPIO_PinAFConfig(AD_SPI_MISO_GPIO_PORT,AD_SPI_MISO_PINSOURCE,AD_SPI_MISO_AF); //PC11¸´ÓÃSPI3µÄMISO
GPIO_InitStructure.GPIO_Pin = AD_SPI_SCK_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //¸´ÓÃ
GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; //50MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //SCK¿ÕÏÐÉèÖÃΪ¸ßµçƽ£¬¹ÊΪÉÏÀ
GPIO_Init(AD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); //³õʼ»¯PC10
GPIO_InitStructure.GPIO_Pin = AD_SPI_MISO_PIN;
GPIO_Init(AD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = AD_CS_PIN;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT ;
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Fast_Speed;
GPIO_Init(AD_CS_GPIO_PORT, &GPIO_InitStructure);
GPIO_SetBits(AD_CS_GPIO_PORT,AD_CS_PIN);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_RxOnly; //ģʽ£¬µ¥Ïß½ÓÊÕģʽ
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //ģʽѡÔñ;Ö÷¿Ø·¢³öSCLKÐźÅ
SPI3->CR1|=1<<10;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; //ÉèÖÃSPIµÄÊý¾Ý´óС
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; //´®ÐÐͬ²½Ê±ÖӵĿÕÏÐ״̬
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; //´®ÐÐͬ²½Ê±ÖÓ²ÉÑù±ßÑØ
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //NSSÓÉÓ²¼þ»¹ÊÇÈí¼þ¿ØÖÆ
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; //·ÖƵϵÊý
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //¸ßλÓÐЧ
SPI_InitStructure.SPI_CRCPolynomial = 7; //CRCУÑé
SPI_Init(AD_SPI, &SPI_InitStructure); //SPI³õʼ»¯
}
u16 SPIx_ReadWriteByte(void)
{
u8 retry=0;
while (SPI_I2S_GetFlagStatus(AD_SPI, SPI_I2S_FLAG_RXNE) == RESET)
{
retry++;
if(retry>200)
return 0;
}
return SPI_I2S_ReceiveData(AD_SPI);
}
1. 不会快的,SPI的还能支持更高的通信速度,理论上DMA存取数据到缓存数组中也应该能跟得上吧(此处不敢确定);2. AD支持的最大SCLK=80MHz;
3. sclk的图像如下所示;
这个SCLK应该没有问题吧
一周热门 更多>