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.

DRV2604L Loading data to RAM and Waveform Sequencer

Other Parts Discussed in Thread: DRV2604L

Hi, I am pretty new to coding and right now I am trying to drive a linear actuator using the DRV2604L. I am unsure as how the format should be when I am loading an array for a waveform into the header and data section. Can anyone guide me through this?

Thank you

  • Hi Anny,

    Have you looked through the datasheet section 8.5.8.2.4? This is a good starting point. How are you trying to program the RAM? We have a RAM manager tool in our Haptic Control Console software.

    Regards,
    Kelly Griffin
    Haptics Application Engineer
  • Hi Kelley, I have indeed looked through that section. So far, this is what I have done in regards to the RAM:

    unsigned char StrongClickHeader[]={
    0x01,0x00,0x04};
    unsigned char StrongClickData[]={
    0x3F,0x09,0x41,0x08
    };

    void initializeRAM() { //PAGE 61
    //---wake up device--
    writeRegister(REG_MODE, MODE_INTTRIG); //0X00
    writeRegister(RAM_REV,0);

    //---write header--- 
    writeRegister(RAM_ADDR_UB,0x00);
    writeRegister(RAM_ADDR_LB, 0x00);
    writeRegister(RAM_DATA,(unsigned char)*StrongClickHeader);


    //---load waveform data
    writeRegister(RAM_ADDR_UB,0x01);
    writeRegister(RAM_ADDR_LB, 0x00);

    writeRegister(RAM_DATA,(unsigned char)*StrongClickData);
    checkRegister(RAM_DATA,"RAM DATA 2");

    }

    What I am uncertain is how to load an array into the RAM and if the code seems correct.

  • Hi, Anny:

    it should be programmed like below:

    unsigned char StrongClickHeader[]={
    0x01,0x00,0x04};
    unsigned char StrongClickData[]={
    0x3F,0x09,0x41,0x08
    };

    void initializeRAM() { //PAGE 61
    //---wake up device--
    writeRegister(REG_MODE, MODE_INTTRIG); //0X00

    //---write header---
    writeRegister(RAM_ADDR_UB,0x00);
    writeRegister(RAM_ADDR_LB, 0x00);
    writeRegister(RAM_DATA,0); //revison byte
    writeRegister(RAM_DATA, StrongClickHeader);


    //---load waveform data
    writeRegister(RAM_ADDR_UB,0x01);
    writeRegister(RAM_ADDR_LB, 0x00);
    writeRegister(RAM_DATA,(unsigned char)*StrongClickData);
    }
  • Thanks for your reply, Peter!

    I am encountering this bug (invalid conversion from 'unsigned char*' to 'uint8_t {aka unsigned char}' [-fpermissive]) 

    with this line: 

    writeRegister(RAM_DATA, StrongClickHeader);

    my function writeRegister is as follows: 

    void writeRegister(uint8_t regstr, uint8_t val) {
    // use i2c
    Wire.beginTransmission(DRV2604L_ADDR);
    Wire.write((byte)regstr);
    Wire.write((byte)val);
    Wire.endTransmission();
    }

    should it be uint8_t*val, or do I have it all wrong?

    Again, thanks!

  • Hi, Anny:

    the writeRegister seems right.

    programming the header should be like this:

    #define ARRAY_LEN(x) ((int)(sizeof(x)/sizeof((x)[0])))

    for(int i=0; i < ARRAY_LEN(StrongClickHeader); i++){

    writeRegister(RAM_DATA, StrongClickHeader[i]);

    }

  • Thanks, Peter! now everything works perfectly!!
  • If I happen to load more than one waveform, do I still write it into the RAM_DATA register or do I have to deal with the Waveform Sequencers (0x04 to 0x0B)?
  • Hi, Anny:

    if you have more than one waveform, and we assume each waveform is different, we need to program the waveforms into DRV2604L in-chip RAM (follow the format defined in the data sheet).
    if you want to play only one effect, just put the effect ID (index) to the sequencer register 0x04, then trigger the playback by GO register (0x0c).
    if you want to play multiple effects, then put the effects into the sequence registers (0x04~0x0b, so maximum 8 effects one time), then use GO register to trigger the playback