关于LMH6401 spi读取id失败的问题
时间:10-02
整理:3721RD
点击:
关键程序如下:
//初始化 void SPI_FLASH_Init(void) { SPI_InitTypeDef SPI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable SPI1 and GPIO clocks */ /*!< SPI_FLASH_SPI_CS_GPIO, SPI_FLASH_SPI_MOSI_GPIO, SPI_FLASH_SPI_MISO_GPIO, SPI_FLASH_SPI_DETECT_GPIO and SPI_FLASH_SPI_SCK_GPIO Periph clock enable */ /*!< SPI_FLASH_SPI Periph clock enable */ macSPI_APBxClock_FUN ( macSPI_CLK, ENABLE ); /*!< Configure SPI_FLASH_SPI_CS_PIN pin: SPI_FLASH Card CS pin */ macSPI_CS_APBxClock_FUN ( macSPI_CS_CLK, ENABLE ); GPIO_InitStructure.GPIO_Pin = macSPI_CS_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(macSPI_CS_PORT, &GPIO_InitStructure); /*!< Configure SPI_FLASH_SPI pins: SCK */ macSPI_SCK_APBxClock_FUN ( macSPI_SCK_CLK, ENABLE ); GPIO_InitStructure.GPIO_Pin = macSPI_SCK_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(macSPI_SCK_PORT, &GPIO_InitStructure); /*!< Configure SPI_FLASH_SPI pins: MISO */ macSPI_MISO_APBxClock_FUN ( macSPI_MISO_CLK, ENABLE ); GPIO_InitStructure.GPIO_Pin = macSPI_MISO_PIN; GPIO_Init(macSPI_MISO_PORT, &GPIO_InitStructure); /*!< Configure SPI_FLASH_SPI pins: MOSI */ macSPI_MOSI_APBxClock_FUN ( macSPI_MOSI_CLK, ENABLE ); GPIO_InitStructure.GPIO_Pin = macSPI_MOSI_PIN; GPIO_Init(macSPI_MOSI_PORT, &GPIO_InitStructure); /* Deselect the FLASH: Chip Select high */ macSPI_FLASH_CS_DISABLE(); 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_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;//128 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7;//7 SPI_Init(macSPIx , &SPI_InitStructure); /* Enable SPI1 */ SPI_Cmd(macSPIx , ENABLE); } //主函数循环读取id . . . . while(1) { macSPI_FLASH_CS_ENABLE(); Delay( 1 ); while (SPI_I2S_GetFlagStatus(macSPIx , SPI_I2S_FLAG_TXE) == RESET); SPI_I2S_SendData(macSPIx , 0x0); while (SPI_I2S_GetFlagStatus(macSPIx , SPI_I2S_FLAG_RXNE) == RESET); DeviceID=SPI_I2S_ReceiveData(SPI1); Delay(1); macSPI_FLASH_CS_DISABLE(); }
spi时序图
实测波形图:
sdi发送0x00,返回的典型值应为0x03
请技术大佬分析下为什么没有sdo返回值.
整一个毫无反应的样子. 我看先查硬件吧, 从焊接情况, 供电检查, 还有信号连接和复位等是否都正常.
供电 焊接都测了 并没有什么问题
供电 焊接都测试了 没发现什么问题
你好,问题解决了吗?最近也在调lmh6401,很多地方不懂,可以请教一下吗?