N32G45X芯片SPI1异常
开发一个称量项目用到了N32G455REL7 通过SPI1读取AD7190的ADC转换值,开始调试时,SPI1口读取AD7190芯片的ID值,芯片内温度都很正常,一次断电后,发现在再也读不到AD芯片了,以为是AD芯片坏了,换几片AD都不行,再换N32G455REL7也是不行,修改配置,一直折腾了好几天都没有一个结果,换STM32芯片,读取正常,后再换N32G455REEL7的SPI2口读取AD芯片的ID,结果正常,反过来再换SPI1口还是不正常。用逻辑分析仪抓包结果如下图,请大家分析如何修改?
void MX_WEIGHT_SPI_Init(void)
{
GPIO_InitTypeGPIO_InitStructure;
SPI_InitTypeSPI_InitStructure;
WEIGHT_SPIx_APBxClock_FUN(WEIGHT_SPIx_CLK, ENABLE);
RCC_EnableAPB2PeriphClk(WEIGHT_GPIO_CLK, ENABLE);
WEIGHT_CS_DISABLE();
GPIO_InitStructure.Pin = WEIGHT_CS_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitPeripheral (WEIGHT_CS_GPIO_Port, &GPIO_InitStructure);
GPIO_InitStructure.Pin = WEIGHT_SCK_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitPeripheral(WEIGHT_SCK_GPIO_Port, &GPIO_InitStructure);
GPIO_InitStructure.Pin = WEIGHT_MOSI_Pin;
GPIO_InitPeripheral(WEIGHT_MOSI_GPIO_Port, &GPIO_InitStructure);
GPIO_InitStructure.Pin = WEIGHT_MISO_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitPeripheral(WEIGHT_MISO_GPIO_Port, &GPIO_InitStructure);
SPI_InitStructure.DataDirection = SPI_DIR_DOUBLELINE_FULLDUPLEX;
SPI_InitStructure.SpiMode = SPI_MODE_MASTER;
SPI_InitStructure.DataLen= SPI_DATA_SIZE_8BITS ;
SPI_InitStructure.CLKPOL = SPI_CLKPOL_HIGH;
SPI_InitStructure.CLKPHA = SPI_CLKPHA_SECOND_EDGE;
SPI_InitStructure.NSS = SPI_NSS_SOFT ;
SPI_InitStructure.BaudRatePres = SPI_BR_PRESCALER_128;
SPI_InitStructure.FirstBit = SPI_FB_MSB;
SPI_InitStructure.CRCPoly = 10;
SPI_Init(WEIGHT_SPIx , &SPI_InitStructure);
/* 使能SPI外设 */
SPI_Enable(WEIGHT_SPIx , ENABLE);
WEIGHT_CS_ENABLE();
}
|