2024-06-25 02:20 AM
At present, when STM32L412 uses the HAL_SPI command to read back the Register, no matter which Register is used, it is 0, but it is normal to use LA to read the data. The waveform is as follows:
Is there any unprocessed program that causes the SPI reading values to be all 0? please help. Thanks!
Below is the current program for reference.
ads131m0xTxBuff[0] = (ads131m0x_CMD_RREG | (0x00<<7)) >> 8;
ads131m0xTxBuff[1] = (ads131m0x_CMD_RREG | (0x00<<7)) & 0xFF;
ads131m0xTxBuff[2] = 0x00;
ads131m0xTxBuff[3] = 0x00;
ads131m0xTxBuff[4] = 0x00;
ads131m0xTxBuff[5] = 0x00;
while(HAL_SPI_GetState(&hspi2) == HAL_SPI_STATE_BUSY);
HAL_GPIO_WritePin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin, GPIO_PIN_RESET);
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive(&hspi2, ads131m0xTxBuff, ads131m0xRxBuff, 3, 10);
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_GPIO_WritePin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin, GPIO_PIN_SET);
while(HAL_SPI_GetState(&hspi2) == HAL_SPI_STATE_BUSY);
HAL_GPIO_WritePin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin, GPIO_PIN_RESET);
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_SPI_Receive(&hspi2, ads131m0xRxBuff, 3, 100);
adc_status = ads131m0xRxBuff[0] <<8;
adc_status |= ads131m0xRxBuff[1] &0xFF;
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_GPIO_WritePin(SPI2_NSS_GPIO_Port, SPI2_NSS_Pin, GPIO_PIN_SET);
Any advice and advice would be greatly appreciated. Thanks!