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.

PCM6360Q1EVM-PDK: An example of a function for writing to the device register

Part Number: PCM6360Q1EVM-PDK
Other Parts Discussed in Thread: USB2ANY

Hello! We need an example of a function for getting a device descriptor and writing to the device register (for example, writing to the address I2C 0x98, register 0xXX, data 0xYY) in C or Python. Thank you.

  • Hi Nikolay,

    The GUI export provides some example code for doing this. Please try this as a starting point!

    typedef unsigned char cfg_u8;
    typedef union {
    struct {
    cfg_u8 offset;
    cfg_u8 value;
    };
    struct {
    cfg_u8 command;
    cfg_u8 param;
    };
    } cfg_reg;

    #define CFG_META_SWITCH (255)
    #define CFG_META_DELAY (254)
    #define CFG_META_BURST (253)

    /* Example C code */
    /*
    // Externally implemented function that can write n-bytes to the device
    // Refer to the device data sheet for more information.
    extern int i2c_write(unsigned char *data, int n);
    // Externally implemented function that delays execution by n milliseconds
    extern int delay(int n);
    // Example implementation. Call like:
    // transmit_registers(registers, sizeof(registers)/sizeof(registers[0]));
    void transmit_registers(cfg_reg *r, int n)
    {
    int i = 0;
    while (i < n) {
    switch (r[i].command) {
    case CFG_META_SWITCH:
    // Used in legacy applications. Ignored here.
    break;
    case CFG_META_DELAY:
    delay(r[i].param);
    break;
    case CFG_META_BURST:
    i2c_write((unsigned char *)&r[i+1], r[i].param);
    i += (r[i].param / 2) + 1;
    break;
    default:
    i2c_write((unsigned char *)&r[i], 2);
    break;
    }
    i++;
    }
    }
    */

    cfg_reg registers[] = {
    #define CHECKSUM (0)
    // -----------------------------------------------------------------------------
    // Reset
    // -----------------------------------------------------------------------------
    // Select Page 0
    { 0x00, 0x00 },
    // Reset Device
    { 0x01, 0x01 },
    // 1mS Delay
    // -----------------------------------------------------------------------------
    // Begin Device Memory
    // -----------------------------------------------------------------------------
    // Page 0 (0x00) Dump
    // Select Page 0
    { 0x00, 0x00 },
    { 0x02, 0x81 },

    Best,

    Zak

  • Yes, I also read the documentation. But where to get the i2c_write and delay functions for Windows?

  • Hi Nikolay,

    This will depend on entirely on the processor you are using which is why they are not defined here. There may be an existing library of such functions for your processor, but if not then you would need to write one yourself.

    Best

    Zak

  • Is there a way other than your PPC3 software to configure the PCM6360Q1EVM-PDK card from a personal computer?
    Or maybe your PPC3 software has a Command Line Interface (CLI) that would allow (without using the GUI) to write the necessary settings to the board from the command line?

  • Hi Nikolay,

    The GUI is the only supported way to communicate with the board from your PC. You can use the I2C master tool to issue I2C register writes directly without having to configure the GUI if you'd like, but this tool still exists in PPC3. Otherwise you would need to use a different board capable of issuing I2C commands from PC like the USB2ANY or Aardvark I2C adapter. 

    Best,

    Zak

  • Thank you for your answer.