AnsweredAssumed Answered

SPI communication between MM9Z1J638 and MC33879

Question asked by Burak Soner on Jul 14, 2016
Latest reply on Aug 1, 2016 by Wolfgang Bihlmayr

Hello,

 

I'm using the MM9Z1J638-based 4-cell lithium ion battery management system reference design shown in the link below:

 

MM9Z1_638, 4-Cell Lithium Battery|NXP

 

In the example software provided for this, the following line is used for SPI communication between the MM9Z1J638 and MC33879.

u16SPIResult = SPITransfer16bit2(u16SPIData);

 

This function sends 2 SPI messages to MC33879 and reads the SPIDR twice, returning the received message in the second SPIDR read:

 

/*! \brief  Transmits a 16bit value via SPI and receives a 16 bit value.

    The transfer is performed twice to receive status feedback.

  @param[in]  u16Data    16bit data to be transmitted

  @param[out] u16        returns 16bit data received 

  \todo operation timeout is missing! Statusbits 

*/

u16 SPITransfer16bit2(u16 u16Data)  {

  while (!SPISR_SPTEF) DO_NOTHING;   //Wait for empty data register         

    SPIDR = u16Data;                     //transmit a 16-bit word (1)

    while (!SPISR_SPIF) DO_NOTHING;   //Wait for receiving data

    (void) SPIDR; //dummy read

 

  while (!SPISR_SPTEF) DO_NOTHING;   //Wait for empty data register         

    SPIDR = u16Data;                     //transmit a 16-bit word 

    while (!SPISR_SPIF) DO_NOTHING;   //Wait for receiving data

    return SPIDR; // contains status data from first write operation (1)

}

 

The comments above the function state that it does this to get status feedback from the MC33879. According to the datasheet of the MC33879 though, this would also be achieved with a single transmit (which could be triggered with the " SPITransfer16bit() " function in the example code). Quote from the MC33879 datasheet:

 

"On each SPI communication, a 16-bit command word is sent to the 33879 and a 16-bit status word is received from the 33879."

 

Is there a specific reason why this double transmit function is used? Although the MC33879 datasheet states it's possible, is it not possible to get a status feedback from the MC33879 with a single transmit?

 

Thanks!

Burak

Outcomes