This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8462: DRV8462 SPI DAISY CHAIN - Unable to decode responses properly

Part Number: DRV8462

Hi,

Can someone please inform me what the response packets would look like for two devices (when daisy chained)? As possibly help me fix up why the received packets are different at the start as thought the status reply should start with 11 which 82 and A0 does not start with 11

I know SDI from MCU to first DRV8462 will look like HDR1 HDR2 A2 A1 D2 D1 but what does the next two packets look like?

I know for three devices they are like this

// SDO1 / SDI      S1 HDR1 HDR2 A2 A2 R1 D2 *
// SDO2 / SDI3    S2 S1 HDR1 HDR2 A3 R2 R1 D3 
// SDO3               S3 S2 S1 HDR1 HDR2 R3 R2 R1 *
The code I have transfers the two headers ie HDR1 0x82 and  HDR2 0xA0 which are saved to dataMSB2 dataMSB1 - how can I get the status byte instead?
 
Packet sent HDR1 HDR2 A2 A1 D2 D1 

Regards

Phillip Bothma

  • // This SPI function is used to write the set device configurations and operating parameters.
    uint16_t spi_writeRegister(uint8_t address, uint16_t data) {
      uint16_t reg_value = 0;

      reg_value |= ((address << SPI_ADDRESS_POS) & SPI_ADDRESS_MASK);  // Adding register address value
      reg_value |= ((data << SPI_DATA_POS) & SPI_DATA_MASK);           // Adding data value

      hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE1));
      digitalWrite(hspi->pinSS(), LOW);  //pull SS low to prep other end for transfer

      uint8_t h1 = 0b10000010;
      uint8_t h2 = 0b10100000;

      uint8_t h11 = hspi->transfer(h1);  // Transmit first Byte, MSB-Byte
      uint8_t h22 = hspi->transfer(h2);  // Transmit Second Byte, LSB-Byte

      uint8_t dataMSBS = ((reg_value >> 8) & 0xFF);
      uint8_t dataLSBS = (reg_value & 0xFF);

      uint8_t dataMSB2 = hspi->transfer(dataMSBS);  // Transmit first Byte, MSB-Byte A2
      uint8_t dataMSB1 = hspi->transfer(dataMSBS);  // Transmit first Byte, MSB-Byte A1

      uint8_t dataLSB2 = hspi->transfer(dataLSBS);  // Transmit Second Byte, LSB-Byte D2
      uint8_t dataLSB1 = hspi->transfer(dataLSBS);  // Transmit Second Byte, LSB-Byte D1

      hspi->endTransaction();
      digitalWrite(hspi->pinSS(), HIGH);  //pull ss high to signify end of data transfer

      if (debug == 2) {
        Serial.print("Wrote: ");
        Serial.print(addPadding(dataMSBS));
        Serial.print(addPadding(dataLSBS));
        String data1 = addPadding(dataMSB2) + "" + addPadding(dataLSB2);
        String data2 = addPadding(dataMSB1) + "" + addPadding(dataLSB1);
        Serial.print(" Received: ");
        Serial.print(data1);
        Serial.print(" ");
        Serial.print(hexToBinary(data1));
        Serial.print(" ");
        Serial.print(" Received: ");
        Serial.print(data2);
        Serial.print(" ");
        Serial.print(hexToBinary(data2));
        Serial.println("");
      }

      //if(address == SPI_CTRL2)
      //    DetermineMicrostepping(data);

      return 0;
    }
  • // This SPI function is used to write the set device configurations and operating parameters.
    uint16_t spi_writeRegister(uint8_t address, uint16_t data) {
      uint16_t reg_value = 0;

      reg_value |= ((address << SPI_ADDRESS_POS) & SPI_ADDRESS_MASK);  // Adding register address value
      reg_value |= ((data << SPI_DATA_POS) & SPI_DATA_MASK);           // Adding data value

      hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE1));
      digitalWrite(hspi->pinSS(), LOW);  //pull SS low to prep other end for transfer

      uint8_t h1 = 0b10000010;
      uint8_t h2 = 0b10100000;

      uint8_t h11 = hspi->transfer(h1);  // Transmit first Byte, MSB-Byte
      uint8_t h22 = hspi->transfer(h2);  // Transmit Second Byte, LSB-Byte

      uint8_t dataMSBS = ((reg_value >> 8) & 0xFF);
      uint8_t dataLSBS = (reg_value & 0xFF);

      uint8_t dataMSB2 = hspi->transfer(dataMSBS);  // Transmit first Byte, MSB-Byte A2
      uint8_t dataMSB1 = hspi->transfer(dataMSBS);  // Transmit first Byte, MSB-Byte A1

      uint8_t dataLSB2 = hspi->transfer(dataLSBS);  // Transmit Second Byte, LSB-Byte D2
      uint8_t dataLSB1 = hspi->transfer(dataLSBS);  // Transmit Second Byte, LSB-Byte D1

      hspi->endTransaction();
      digitalWrite(hspi->pinSS(), HIGH);  //pull ss high to signify end of data transfer

      if (debug == 2) {
        Serial.print("Wrote: ");
        Serial.print(addPadding(dataMSBS));
        Serial.print(addPadding(dataLSBS));
        String data1 = addPadding(dataMSB2) + "" + addPadding(dataLSB2);
        String data2 = addPadding(dataMSB1) + "" + addPadding(dataLSB1);
        Serial.print(" Received: ");
        Serial.print(data1);
        Serial.print(" ");
        Serial.print(hexToBinary(data1));
        Serial.print(" ");
        Serial.print(" Received: ");
        Serial.print(data2);
        Serial.print(" ");
        Serial.print(hexToBinary(data2));
        Serial.println("");
      }

      //if(address == SPI_CTRL2)
      //    DetermineMicrostepping(data);

      return 0;
    }
    REPONSE
    11:08:45.139 -> Wrote: 057A Received: 823A 10000010 00111010  Received: A03A 10100000 00111010
    
  • Think the reply packet from SDO2 will be the following - which seems right

    // SDO2   S2 S1 HDR1 HDR2 R2 R1 
  • Figured out that the responses for the status is stored in h11 h22 - so this can be resolved thanks anyway