I have a sensor with a 3-wire SSC interface, which is SPI compatible, but only has one bidirectional data line. Now I try to read this sensor (https://www.infineon.com/dgdl/Infineon-Angle_Sensor_TLE5012B-UM-v01_02-en-UM-v01_02-EN.pdf?fileId=5546d46146d18cb40146ec2eeae4633b) out and it sends me data back, but since MISO and MOSI are shorted together (as recommended from the chip manufacturer), the data is blocked after the 470Ohm data line resistance, because MOSI needs to go high-impedance after the command was sent.
So, how can I achieve a high impedance MOSI pin on a STM32F410CBU6? I could define it as an input, but then I need to re-init the SPI interface. Is there a simpler solution with less overhead?
Edit: I tried now to configure the SPI in the half-duplex mode. Since I use CubeMX, the configuration for this was easy, but I have no success yet. When the SPI is in the half-duplex mode, the SCK seems to have some small offset (maybe about 0.4V) and the MOSI line has also a strange behaviour. When I switch to the full-duplex mode, this behaviour is gone. What could cause this? I'm reading the sensor our likes this:
HAL_GPIO_WritePin(SPI_CS_PORT, SPI_CS, LOW); spi_pos->Instance->CR1 |= (1<<BIDIOE); HAL_SPI_Transmit(spi_pos,&command,1,1); spi_pos->Instance->CR1 &= ~(1<<BIDIOE); asm("nop"); // Since sensor needs some ns to switch to sender mode HAL_SPI_Receive(spi_pos,data,size,1); HAL_GPIO_WritePin(SPI_CS_PORT, SPI_CS, HIGH);
The SPI is configured as follows:
/* SPI2 parameter configuration*/ hspi2.Instance = SPI2; hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_2LINES; hspi2.Init.DataSize = SPI_DATASIZE_16BIT; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPhase = SPI_PHASE_2EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCPolynomial = 15;