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.