2024-01-30 11:02 PM
Hello,
I'm trying to do SPI communication with an ADE1201 chip through an STM32H753VIT6 chip.
The maximum allowed frequency of the ADE1201 is 10MHZ, so I set the SPI to communicate with the MCU at 6.25MHZ.
(The clock for SPI communication is 25MHZ, and I set the PRESCALER value to 4).
However, a strange phenomenon was observed.
I observed through the scope that the SPI CS signal should be 0 continuously, but it turns to 1 in the middle.(See attached photo).
However, if I set the PRESCALER value to 8, the CS signal is continuously output as 0.
What could be the cause? And how can I solve this?
Could this be due to the usage of HAL_SPI_TransmitReceive function?
Solved! Go to Solution.
2024-02-01 03:22 AM
Hello @KDG ,
As I can see, here some remarks :
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-31 06:03 AM
Hello @KDG,
Thank you for your question !
Here some remark :
Kind Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-31 05:12 PM
Thanks for the remark @Pierre_Paris
These are the answers for your remarks
static void MX_SPI4_Init(void)
{
/* USER CODE BEGIN SPI4_Init 0 */
/* USER CODE END SPI4_Init 0 */
/* USER CODE BEGIN SPI4_Init 1 */
/* USER CODE END SPI4_Init 1 */
/* SPI4 parameter configuration*/
hspi4.Instance = SPI4;
hspi4.Init.Mode = SPI_MODE_MASTER;
hspi4.Init.Direction = SPI_DIRECTION_2LINES;
hspi4.Init.DataSize = SPI_DATASIZE_8BIT;
hspi4.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi4.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi4.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi4.Init.TIMode = SPI_TIMODE_DISABLE;
hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi4.Init.CRCPolynomial = 0x0;
hspi4.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi4.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi4.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi4.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi4.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi4.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi4.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi4.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi4.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi4.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI4_Init 2 */
/* USER CODE END SPI4_Init 2 */
}
And the API ISI wonder if this would be enough for your remarks.
Thank you.
Sincerely,
KDG
2024-02-01 03:22 AM
Hello @KDG ,
As I can see, here some remarks :
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-02 12:34 AM
Thanks @Pierre_Paris
By your remarks, my problem is solved.