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.

Further question on loading lm48901 coefficient memory from dat2tab table

I am loading the coefficient memory over I2C just fine, but I would like confirmation on the byte order of the load.

I am using the table generated from the tool Royce provided me; the table is of four-byte values:

#define LM48901_TAB_LEN  0x500
const unsigned long lm48901Table0[LM48901_TAB_LEN] = {
  0x002effc4,
         ...

looking at the first value as an example, would the register be loaded over I2C as

<dev_addr> 00 00      00 2e ff c4      (usual 7-byte I2C write packet)

OR

<dev_addr> 00 00      c4 ff 2e 00

There's no byte order info in the file generated by Dat2Tab, and not much documented info about the coefficient memory, either.

Again, any input is appreciated.

Ron Sturtevant

  • Hi Ron,

    Royce should be getting back to you tomorrow; he was out today.

    Best Regards,

    JD

  • Ron,

    I believe its the same format as the data order into the device, 7:0, 15:8, 23:16, 31:24. Let me confirm with the software guys.

    Regards,

    royce

  • Royce,

    I think the data order is the same as the control registers as well; but how it was stored in the table generated from dat2tab is what I'm unsure of.  Looking forward to an answer tomorrow.

    Ron

  • Ron,

    Turns out the Dat2Tab format is reversed.  Its 31:24 23:16 15:8 7:0. 

    Regards,

    royce

  • Royce,

    Thanks for the reply.  We figured out, through testing, the byte order  we needed to send to the lm48901. 

    given that the registers are loaded   7:0  15:8  23:16  31:24, it actually works out well that the Stellaris uses little-endian format, since the LSB of the unsigned long is pointed to first when I assign a char pointer to the array element.

    So,

    unsigned char *pData;

    pData = (unsigned char *) &lm48901Table[i];      // example:  0x002effc4

    reg.data7_0[0] = *pData++;           // loads 0xc4

    reg.data15_8[1] = *pData++;          // loads 0xff

    reg.data23_16[2] = *pData++;          // loads 0x2e

    reg.data31_24[3] = *pData;              // loads 0x00

    works great. At least I think so, as when I switch the chip to spatial mode, I get recognizable sound from the chip.  I would assume incorrectly loaded coefficients would greatly distort the audio.

    As a suggestion, it would simplify things for others dealing with big vs little endian issues if a modified Dat2Tab stored the coefficient values as unsigned char, four bytes per line, with markers in the comments (something like this):

    unsigned char lm48901Coefficient[0x500] = {

    // 7:0    15:8     23:16   31:24

    0xc4,    0xff,       0x2e,    0x00,

    etc, etc, etc.