2025-05-22 9:18 AM
Hi all,
I'm Fairly new to both STM32 and the SPI protocol. I'm struggling to get communication working.
MCU: STM32F722RETX
Devices: GS12281 & GS12170
I have both devices connected to my SPI1 bus with SPI initialized as follows:
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
The device(s) Datasheets specify a 48bit (3 word) communication exchange for read/write operations. I've minimized the test code to the bare minimum to try writing to the GPIO register of the GS12281 to toggle an LED on/off. Using an evaluation board with demo software, the led toggles as expected when i send the address/data pairs. However my board does not.
uint8_t tx[6];
tx[0] = (CW1 >> 8) & 0xFF; // MSB of CW1
tx[1] = CW1 & 0xFF; // LSB of CW1
tx[2] = (CW2 >> 8) & 0xFF; // MSB of CW2
tx[3] = CW2 & 0xFF; // LSB of CW2
tx[4] = (DW >> 8) & 0xFF; // MSB of DW
tx[5] = DW & 0xFF; // LSB of DW
HAL_GPIO_WritePin(HDMI_SDI_1_CS_GPIO_Port, HDMI_SDI_1_CS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
HAL_SPI_Transmit(&hspi1, tx, 6, HAL_MAX_DELAY);
HAL_Delay(1);
HAL_GPIO_WritePin(HDMI_SDI_1_CS_GPIO_Port, HDMI_SDI_1_CS_Pin, GPIO_PIN_SET);
Any help would be greatly appreciated.
2025-05-23 12:57 AM
Hello @J_Godwin
@J_Godwin wrote:
Using an evaluation board with demo software, the led toggles as expected when i send the address/data pairs. However, my board does not.
Which demo you are talking about ? and which eval board?
Please update your code as to ensure that the data are transmitted as expected without error.
if (HAL_SPI_Transmit(&hspi1, (uint8_t*)tx, 6, HAL_MAX_DELAY) != HAL_OK)
{
Error_handler();
}
Could you check the trafic on the bus using logic analyser?
2025-05-23 1:09 AM
The first thing to do is to look at the SPI lines with an oscilloscope - verify that good, clean signals are actually present at all the required device pins.
No amount of fiddling with the software will fix bad connections:
Then check that what's being sent actually matches the specifications - an analyser will help with this; cheap logic analysers are widely available on the likes of Amazon, ebay, et al.
If it doesn't match the specs, that will tell you what to look for in the software setup...
#DebugSPI
2025-05-23 1:17 AM
@J_Godwin wrote:Devices: GS12281 & GS12170
What are they?
GS12281: https://www.semtech.com/products/broadcast-video/cable-drivers/gs12281 ?
GS12170: https://www.semtech.com/products/broadcast-video/av-interface-protocol-conversion/gs12170 ?
@J_Godwin wrote:MCU: STM32F722RETX.
What board is it on ?
Please provide schematics - how is everything connected?
Some good, clear photos of the setup may also help.
Please see: How to write your question to maximize your chances to find a solution.