Issue Communicating with MC33772C via MC33664 – Always Receiving 0x00 or 0xFF on SPI2

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Issue Communicating with MC33772C via MC33664 – Always Receiving 0x00 or 0xFF on SPI2

ソリューションへジャンプ
1,469件の閲覧回数
kevinyuee
Contributor III

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,

ラベル(1)
0 件の賞賛
返信
1 解決策
1,410件の閲覧回数
guoweisun
NXP TechSupport
NXP TechSupport

You use the STM32 communicate with MC33664 with SPI then transfer it into TPL signal to MC33772,right?

If so no problem.

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
1,351件の閲覧回数
kevinyuee
Contributor III

Hi,
    When communicating with mc33664 via spi, must the high and low levels of sclk be strictly maintained between 240ns and 260ns, or is the corresponding delay set according to the frequency of SPI frequency, with a maximum value of 240ns and a minimum value of 260ns?

    In addition, I hope to provide an initialization register writing instruction(such as 00 00 00 01 31 7B) and a corresponding register reading instruction so that I can confirm that my communication is working.

Thanks!

 
 
0 件の賞賛
返信
1,351件の閲覧回数
kevinyuee
Contributor III

Hi,
    When communicating with mc33664 via spi, must the high and low levels of sclk be strictly maintained between 240ns and 260ns, or is the corresponding delay set according to the frequency of SPI frequency, with a maximum value of 240ns and a minimum value of 260ns?

    In addition, I hope to provide an initialization register writing instruction(such as 00 00 00 01 31 7B) and a corresponding register reading instruction so that I can confirm that my communication is working.

kevinyuee_0-1750774614253.png

Thanks!

 
 
0 件の賞賛
返信
1,423件の閲覧回数
guoweisun
NXP TechSupport
NXP TechSupport

HI 

That's better for your refer to our example code firstly then porting in your side.

https://www.nxp.com/products/MC33771C?ticket=ST-704-cN1mrl5w-tUifVP9OeiwNd0dYC8-nxp#mySoftware

You can download it from below link:

guoweisun_0-1750151139579.png

Thanks!

1,414件の閲覧回数
kevinyuee
Contributor III

Hi guoweisun,

Thank you for your prompt response and for providing the link to the example code for reference. I will review the content and make sure to follow the suggested steps. Your assistance is greatly appreciated.
By The way, I'm using the stm32F407 to connect to the mc33664 via spi and then forward it to the mc33772c. Will this have any impact?

Best regards,
Kevin

0 件の賞賛
返信
1,411件の閲覧回数
guoweisun
NXP TechSupport
NXP TechSupport

You use the STM32 communicate with MC33664 with SPI then transfer it into TPL signal to MC33772,right?

If so no problem.

0 件の賞賛
返信
1,413件の閲覧回数
kevinyuee
Contributor III
I configured the spi of stm32 according to the spi configuration of mc33664 and raised the en pin of mc33664 when powering on to put it into working mode. The format of the data frame was sent in the format of mc33772c.
0 件の賞賛
返信