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.

BQ79616EVM-021: Error in sample codes

Part Number: BQ79616EVM-021
Other Parts Discussed in Thread: BQ79616

Hi.

Just wanted to let you know that there are some memset errors in the sample codes for BQ79616 and BQ79600 (UART and SPI).

The lines

        memset(pData, 0, sizeof(pData));

use sizeof(pData), but pData is a Pointer to an array, passed as parameter. This means only the first "machine address width" bytes are being set to 0. Parameter bLen should have been used instead (but while considering the frame bytes and the TOTALBOARDS number).

This is minor since a successful following receive will overwrite that anyway.

Best regards

  • Further:

    There is an unused function that does not do what the name suggests. I would expect translating a float voltage to ADC raw int representation.

      uint16_t volt2Byte(float volt)
      {
         return (uint16_t)~((int16_t)((-volt/0.00019073)-1.0));
      }

    For the regular use case, converting positive voltages, application of the complement is wrong. You just need the division and the cast for positive voltages. I have not further checked this implementation but the negation of volt looks suspicious as it surprises the caller.

  • Julian,

    Thanks for this feedback. We will look into these items for any future sample code updates