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.

MCF8316AEVM: Read values from RAM (Volatile) Register Map by Code CCS

Part Number: MCF8316AEVM
Other Parts Discussed in Thread: MCF8316A, MSP430FR2355

Hi team,

We have a fan design project. Based on MCF8316EVM board design of TI, we designed own MCF8316AEVM board with a GUI connection for the first design version. We ran successfully our motor through MCF8316A GUI 1.1.8 by setting up parameters and following the construction Tunning Guide.

In order to master the parameters and speed adjustment, we decided to run the motor by embedding CCS programming without going through the app GUI.

I would like to thank Eric Chen for providing the code file:

According to that, we could write and read EEROM by CCS v12.0. However, it is just a connection with EEROM. And now, we want to read values from RAM (Volatile) register map just like when we used GUI to read motor status (BEMF, Speed, phase voltage, phase current, Id, Iq, Vd, Vq ref.,,,)

Could you show me how to do it and provide source code to read the values?

And I want to set speed reference through I2C by coding CCS. What do I have to do to control the speed motor by CCS?

Regards,

Vuong N.T.

 

  • Hi Vuong,

    I will modify the code slightly and provide the updated project next week.

    Regards,
    Eric C.

  • Hi Eric Chen,

    I am extremely interested in mastering the GUI software to adjust parameters dynamically.  Therefore, I really hope you could provide GUI source code. Here is my email: ntvuong@most.gov.vn. You can provide by email. Thank you !

    Regards,

    Vuong N.T.

  • Hi Vuong, 

    Our team is out of office today for a US holiday, but will be back in office next week. 

    Please anticipate a delayed response until then, but we'll get back to you with a comment on your questions at soonest convenience. 

    Best Regards, 
    Andrew 

  • I really hope you could provide GUI source code

    Regards,

    Vuong N.T.

  • Hi Vuong,

    The RAM registers can be accessed using the same I2C read/write commands in the HardwareI2C_MSP430FR2355_MCF8316AEVM.

    However, to access the ALGORITHM_VARIABLE RAM registers, the code needs to be slightly modified since the algorithm variable addresses are 12-bit instead of 8-bit.

    When constructing the control word in the I2C command, the lines:

    line 143    // Construct the 24 bit control word (refer to datasheet section 7.6.2.1)
    line 144    char control_word[3] = {0x10, 0x00, addr&0xFF};

    line 222    // Construct the 24 bit control word (refer to datasheet section 7.6.2.1)
    line 223    char control_word[3] = {0x90, 0x00, addr&0xFF};

    needs to be changed to:

    line 143    // Construct the 24 bit control word (refer to datasheet section 7.6.2.1)
    line 144    char control_word[3] = {0x10, (addr&0x0000FF00)>>8, addr&0x000000FF};

    line 222    // Construct the 24 bit control word (refer to datasheet section 7.6.2.1)
    line 223    char control_word[3] = {0x90, (addr&0x0000FF00)>>8, addr&0x000000FF};

    Please find the updated CCS project: 7444.HardwareI2C_MSP430FR2355_MCF8316AEVM.zip

    Then the I2C_read32() can be used to read from the algorithm variable registers, such as:

    I2C_read32(0x210, &result_var, I2C_TIMEOUT);

    To set the speed reference through I2C, you simply need to

    • set the PIN_CONFIG.SPEED_MODE register to 'Register Override mode'
    • control speed reference by setting the ALGO_CTRL1.DIGITAL_SPEED_CTRL register

    Regards,
    Eric C.

  • Hi Erics,

    However, to access the ALGORITHM_VARIABLE RAM registers, the code needs to be slightly modified since the algorithm variable addresses are 12-bit instead of 8-bit.

    Yes, I saw it and and followed your instruction.

    Then the I2C_read32() can be used to read from the algorithm variable registers, such as:

    Could you share the source code for I2C_read32() for me?

    Regards,

    Vuong N.T.

  • Eric,

    control speed reference by setting the ALGO_CTRL1.DIGITAL_SPEED_CTRL register

    Yes. But I want to control speed reference by code ccs, not by GUI. So could you help me with the code?

  • Hi Vuong, 

    Eric is currently out of office but should be back in office next week to give you a comment on next steps. 

    Best Regards, 
    Andrew 

  • Hi Vuong,

    The source code of the I2C_read32() is contained within the main.c file of the CCS project that I've attached in my response above.

    Example code to set the OVERRIDE bit and change DIGITAL_SPEED_CTRL to 10%, 53%, and 100%:

        // Temporary variable
        long read_result;
        
        // First read the PIN_CONFIG register so that we don't affect other bits when setting SPEED_MODE
        I2C_read32(0xA4, &read_result, I2C_TIMEOUT);
        
        // Set the PIN_CONFIG.SPEED_MODE bitfield to Register Override Mode (2h) while retaining other bits
        I2C_write32(0xA4, (read_result & (~0x00000003)) | 0x00000002, I2C_TIMEOUT);
        
        /*
         * DIGITAL_SPEED_CTRL is 15-bits, so max value is 32767 = 100% speed cmd
         * Multiply 32767 by speed cmd percentage, then bit shift left by 16 before writing to ALGO_CTRL1 register
         */
        
        // Set the ALGO_CTRL1.DIGITAL_SPEED_CTRL bitfield to 10%
        I2C_write32(0xEC, ((int)(0.10 * 32767)) << 16, I2C_TIMEOUT);
        
        // Set the ALGO_CTRL1.DIGITAL_SPEED_CTRL bitfield to 53%
        I2C_write32(0xEC, ((int)(0.53 * 32767)) << 16, I2C_TIMEOUT);
        
        // Set the ALGO_CTRL1.DIGITAL_SPEED_CTRL bitfield to 100%
        I2C_write32(0xEC, ((int)(1.00 * 32767)) << 16, I2C_TIMEOUT);

    Example code to read Algorithm Variables such as the ALGORITHM_STATE and SPEED_FDBK:

        // Temporary variable
        long read_result;
        
        // Read ALGORITHM_STATE algorithm variable
        I2C_read32(0x210, &read_result, I2C_TIMEOUT);
        
        // Read SPEED_FDBK algorithm variable
        I2C_read32(0x752, &read_result, I2C_TIMEOUT);

    Regards,
    Eric C.

  • Hi Eric,

    The source code of the I2C_read32() is contained within the main.c file of the CCS project that I've attached in my response above.

    Example code to set the OVERRIDE bit and change DIGITAL_SPEED_CTRL to 10%, 53%, and 100%:

    I followed your source code and it gave good results. However, to code to read SPEED_FDBK and another RAM's parameters,
    the results is incorrect.


    Could you gave me an explanation as to how to correct the code?

    Regards,
    Vuong N.T.
  • Hi Vuong,

    Each RAM algorithm variables have their own ways of being interpreted from register hex value into the final meaningful unit. Please refer to the datasheet description of each of the algorithm variable for what additional calculation is needed to convert the value of each variable from the register hex value into the corresponding unit.

    For instance, for the SPEED_FDBK register:

    You would need to divide the read_result by 2^(27) then multiply by the value that's configured in the CLOSED_LOOP4.MAX_SPEED register in order to obtain the final estimated speed in Hz.

    Regards,
    Eric C.