2026-01-17 7:30 AM - last edited on 2026-01-17 1:19 PM by mƎALLEm
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:
So i configure my SPI :
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
I hope someone can help me
Thank you
Sergio
Solved! Go to Solution.
2026-01-19 12:07 AM
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.
2026-01-18 3:57 AM
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);
2026-01-18 4:20 AM
i try but still dosen't work
from the datasheet
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 */
}
2026-01-18 10:19 AM
As you did before, you should send 0x2000 and you are sending 0x0000.
2026-01-18 11:03 AM
Sorry, in the last post i try to send 0x0000 is another register , is correct what i did but still don't work. I find one doument on internet and this say
what confuse me is CPOL and CPHA
2026-01-19 12:07 AM
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.