2022-10-10 03:43 AM
I've got a strange situation with a custom board with two STM32F4 chips. My master STM32F4 transmits data over SPI in blocking mode every few 100ms. At the moment the data size is 12 bytes but in theory it should be any size. The Slave chip is in SPI interrupt mode, so when all 12 bytes have been transferred an interrupt is generated on the slave. This interrupt is never generated. Putting a logic analyser onto the SPI pins, the slave only ever transmits the first bye of the 12 byte array:
This explains why the interrupt is never generated on the slave, because the other 11 bytes are never transmitted. What isn't clear however, is why this is happening. I then change the master to only transmit two bytes and I get the same result:
But strangely when I change the master to transmit only a single byte, I get only the last byte transmitted instead, and this is repeated. I'd expect the slave to transmit each byte in the array sequentially when it is requested by the Master. It's really strange.
For the master, the variable declarations:
uint8_t test_byte[1];
uint8_t test_byte2[1];
and later in the software, the blocking SPI transceive request:
HAL_SPI_TransmitReceive(&hspi3, test_byte, test_byte2, sizeof(test_byte), HAL_MAX_DELAY);
for the slave, the variables:
uint8_t blah[12] = {15,2,3,4,5,6,7,8,9,10,11,12};
uint8_t blah2[12] = {0};
and I declare the SPI transceive before my main while loop:
HAL_SPI_TransmitReceive_IT(&hspi3, blah, blah2, sizeof(blah));
and the SPI config in CubeMX:
All variables declared are global, so there is no issues with scope. Is there anything obvious that may be a mistake or that I could try? I can't understand why with a multiple byte transmission the slave will only send a repeated first byte but then with a single byte transmission the slave will only send the final byte. Any help or suggestions would be great. Thanks
2022-10-10 08:40 AM
Read out and check/post content of SPI and related GPIO registers in slave, before and after the one byte transaction.
JW