SPI sends on first read 48 clocks, then always 32 clocks and returns wrong data
Good morning
Seems I come a little further with my GPIB Nucleo-F207ZG project where ports stopped responding...
The initialization for the SPI1 looks like:
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
hspi1.Init.DataSize = SPI_DATASIZE_16BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 10;So I can read out an attached MAX31855 ADC like:
uint16_t tempdata[2];
HAL_SPI_Receive(&hspi1, tempdata, 2, 1000);The first time I call HAL_SPI_Receive() I see on my scope that it sends out 48 clock cycles...
but the temperature is returned fine from MXA31855...which is 0x01A0 for example...stripping of the last bits gets me the celsius degrees...so 0x01A0 << 4 = 26 degrees...
On the next read SPI1 sends 32 clock cycles...and I see that the returned data from MAX31855 is correct....but the function returns always 0x0000.
On subsequent calls to HAL_SPI_Receive() I receive then 0x1B50...so somehow the returned data seems to be shifted.....
So only the first call sends back correct data from SPI1...
Any ideas what is going wrong here?
thanks in advance
richard
