Dear NXP Technical Support Team,
I’m currently working on a battery management system using the MC33772C, interfaced via the MC33664 isolated transceiver. I am encountering a persistent communication issue and would appreciate your assistance.
I attempted to send instructions to mc33664 via muc spi 1, then mc33664 forwarded them to mc33772c, and finally spi 2 received the corresponding data. But now I can only receive all zeros or all fs all the time.
As soon as I powered on, I raised the enable pin of the mc33664 to put it into normal mode. The configurations of spi1 and spi2 were the same, both being full-duplex, mode 0, master mode. The following are my spi receiving and sending functions:
/**
* @brief Sends 6 bytes of data via SPI with timeout and error logging.
* @Param data: Pointer to the data buffer to send. Must be 6 bytes.
* @retval uint8_t: 0 if successful, non-zero if timeout occurred.
*/
uint8_t SPI_Send6Bytes_Timeout(uint8_t* data)
{
uint32_t timeout;
SPI_MC3366_CS_LOW(); // Manually assert CS (active low)
for (int i = 0; i < 6; i++) {
// Wait for TX buffer empty (TXE = 1)
timeout = SPI_TIMEOUT;
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET) {
if (--timeout == 0) {
printf("SPI transmit timeout: TXE[%d]\r\n", i);
return 1;
}
}
SPI_I2S_SendData(SPI1, data[i]); // Write data to SPI data register
(void)SPI_I2S_ReceiveData(SPI1); // Clear RXNE by dummy read
// Wait for SPI not busy (BSY = 0)
timeout = SPI_TIMEOUT;
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET) {
if (--timeout == 0) {
printf("SPI transmit timeout: BSY[%d]\r\n", i);
return 2;
}
}
}
SPI_MC3366_CS_HIGH(); // Deassert CS
return 0; // Success
}
/**
* @brief Receives 6 bytes of data via SPI with timeout and error logging.
* @Param out_buf: Pointer to the buffer to store received data (must be at least 6 bytes).
* @retval uint8_t: 0 if successful, non-zero if timeout occurred.
*/
uint8_t SPI_Receive6Bytes_Timeout(uint8_t* out_buf)
{
uint32_t timeout;
SPI_MC3366_RX_CS_LOW(); // Manually assert RX CS (active low)
for (int i = 0; i < 6; i++) {
// Wait for TX buffer empty before sending dummy byte
timeout = SPI_TIMEOUT;
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET) {
if (--timeout == 0) {
printf("SPI receive timeout: TXE[%d]\r\n", i);
return 1;
}
}
SPI_I2S_SendData(SPI2, 0xFF); // Send dummy byte to trigger clock
// Wait for RX buffer not empty (RXNE = 1)
timeout = SPI_TIMEOUT;
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET) {
if (--timeout == 0) {
printf("SPI receive timeout: RXNE[%d]\r\n", i);
return 2;
}
}
out_buf[i] = SPI_I2S_ReceiveData(SPI2); // Read received data
}
SPI_MC3366_RX_CS_HIGH(); // Deassert RX CS
return 0; // Success
}
The sent initialization instruction is 00 01 01 00 10 75.
The sent read instruction is 00 00 00 01 31 7B.
Thank you for your support!
Best regards,