[信息] [问答] AD2S1210使用SPI2通信,但是SCLK一直没有串行时钟输出...

[复制链接]
1026|13
 楼主| stormwind123 发表于 2021-4-16 15:02 | 显示全部楼层 |阅读模式

  • void SPI2_Init(void)
  • {
  •   GPIO_InitTypeDef  GPIO_InitStructure;
  •   SPI_InitTypeDef  SPI_InitStructure;
  •         RCC_APB2PeriphclockCmd(RCC_APB2Periph_GPIOB, ENABLE );//
  •   RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE );//
  • GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 |  GPIO_Pin_15;
  • GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;  //PB13/14/15
  • GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  • GPIO_Init(GPIOB, &GPIO_InitStructure);//
  • GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 ;
  • GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  • GPIO_Init(GPIOA, &GPIO_InitStructure);
  •         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(SPI2, &SPI_InitStructure);
  •         SPI_Cmd(SPI2, ENABLE);
  •         SPI2_ReadWriteByte(0xFF);

复制代码
LM莫 发表于 2021-4-17 20:21 | 显示全部楼层
SCLK没有输出,说明SPI的初始化都没有完成,建议参考官方的例程进行初始化。
yangjiaxu 发表于 2021-4-17 23:49 | 显示全部楼层
用示波器,逻辑分析仪配合仿真抓一下
mooern 发表于 2024-9-23 13:46 | 显示全部楼层
调试好了没?做的咋样?
powerantone 发表于 2024-11-22 11:58 | 显示全部楼层
SPI2的初始化配置可能不正确
flycamelaaa 发表于 2024-11-22 12:01 | 显示全部楼层
检查连接线路有没有断路或短路现象。
probedog 发表于 2024-11-22 13:09 | 显示全部楼层
检查SPI2的时钟是否已使能
classroom 发表于 2024-11-22 14:26 | 显示全部楼层
SPI接口配置不对?
laocuo1142 发表于 2024-11-22 15:56 | 显示全部楼层
检查AD2S1210的片选信号(CS)是否已正确配置并激活。
发送到工地施工 发表于 2024-12-30 23:58 | 显示全部楼层
在 STM32 中,RCC_APB2PeriphClockCmd() 和 RCC_APB1PeriphClockCmd() 是用来使能外设时钟的。建议将它们修改为标准的 RCC_APB1PeriphClockCmd() 或 RCC_APB2PeriphClockCmd(),并确保正确启用相应的外设时钟。
慢动作 发表于 2024-12-31 00:07 | 显示全部楼层
你提到使用了 SPI2_ReadWriteByte(0xFF) 函数。确保 SPI2_ReadWriteByte() 函数已经实现,或者使用 HAL 库函数来实现数据的发送与接收。
申小林一号 发表于 2024-12-31 16:13 | 显示全部楼层
这个是作为从站的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

605

主题

3747

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部