Skip to main content
SGian.1
Associate III
January 17, 2026
Solved

stm32g031:trying to communicate with MC33HB2000EX over SPI

  • January 17, 2026
  • 1 reply
  • 362 views

Hi there !

here i'm for another question, are a day i'm go crazy with the SPI interface . I try to comunicate with MC33HB2000EX 10 A H-bridge, SPI programmable brushed DC motor driver. The datasheet write that:

Immagine 2026-01-17 160313.pngImmagine 2026-01-17 160349.pngImmagine 2026-01-17 160422.png

So i configure my SPI :

Immagine 2026-01-17 160630.png

and when i send data with 

uint16_t spiData=0x2000;
uint16_t spiRxData = 0x0000;

i reset the CS pin

HAL_SPI_TransmitReceive_IT(&hspi1,(uint8_t*)&spiData,(uint8_t*)&spiRxData,1);

i wait the callback function and i set the CS pin 

no one data come out from MISO and i put on my analaizer and i don't understand why the clock start to logic high and no from logic low i don't know if is the real problem 

Immagine 2026-01-17 162826.png

 

I hope someone can help me 

Thank you 

Sergio

Best answer by AA1

How do you know it doesn't work?

Show the signals.

I think CPOL = 0 (low) and CPHA = 1 (2nd edge). The other possibility is CPOL = 0 and CPHA = 0.

Maybe 0x2000 is not the right command.

 

1 reply

AA1
Senior III
January 18, 2026

First you need to understand how SPI works. To receive, you need to send something. I only see 16 clocks.

Try this:

// send command
HAL_SPI_Transmit_IT(&hspi1,(uint8_t*)&spiData,1);

// receive response
HAL_SPI_TransmitReceive_IT(&hspi1,(uint8_t*)&spiData,(uint8_t*)&spiRxData,1);

 

SGian.1
SGian.1Author
Associate III
January 18, 2026

i try but still dosen't work 

Immagine 2026-01-18 131011.png

 

from the datasheet

Immagine 2026-01-18 131158.png

 

and i configurate my SPI in this way :

CPOL = low

CPHA 0 2 Edge 

Baud rate 500Khz

 

and my code is very simple

void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef * hspi)
{
 
	test=1;
}
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef * hspi)
{
 test=1;
}

HAL_Delay(500);
HAL_GPIO_WritePin(GPIOA, SPI1_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit_IT(&hspi1,(uint8_t*)&spiData,1);
while(test==0);
test=0;
HAL_SPI_TransmitReceive_IT(&hspi1,(uint8_t*)&spiData,(uint8_t*)&spiRxData,1);
while(test==0);
 while (1)
 {
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }

 

AA1
Senior III
January 18, 2026

As you did before, you should send 0x2000 and you are sending 0x0000.