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.

MCF8316C-Q1: I2C Write has no effect

Part Number: MCF8316C-Q1
Other Parts Discussed in Thread: MCF8316AEVM, MOTORSTUDIO

Tool/software:

Hello, 

I designed a custom board with a MCF8316C-Q1 driver interfaced with a MCU. I developed a driver to write and read the registers via I2C, without CRC.

I succeeded in doing the following : 

  1. Read a register content
  2. Write new content to that register
  3. Readback that new value from the register

Therefore, I believe my implementation is fine. However, the change is never effective. Meaning, it is not reflected on the chips behavior. 

The hardware pins are as follows : 

  • DRVOFF: Low
  • SPEED: Low (intended to be used in I2C speed control)
  • BRAKE: Low
  • DIR: Low
  • ALARM : LOW
  • Fault: high-Z

I have a MCF8316AEVM on hand. I wired the I2C lines to my circuit and can control the driver as intended through MotorStudio. Therefore, the issue is not with the hardware design or soldering. The hardware pins are also set properly.

Am I missing some step when programming the registers ? I do not intend to write the EEPROM, so I am not calling the register 0x000000EA with EEPROM Read / Write bit. But is there another bit that should be raised in order for the register to be applied  ?

If that can help, here is a snippet from my I2C write function. The forming of the address byte is not shown here. 

Thank you !

// Build 24 bits Control Word : datasheet 7.6.2.1
// WRITE operation: OP_R/W = 0b0;
controlWord = 0b0 << 23;
// CRC Disabled: CRC_EN = 0b0;
controlWord |= 0b0 << 22;
// Data Length is 32 bits: DLEN = 0b01
controlWord |= 0b01 << 20;
// Memory Section: MEM_SEC = 0x0
// Memory Page: MEM_PAGE = 0x0
// Memory address : is casted on 12 bits
controlWord |= address & 0xFFF;

mfc8316c->i2cData.writeBuffer[0] = (controlWord >> 16) & 0xFF;
mfc8316c->i2cData.writeBuffer[1] = (controlWord >> 8) & 0xFF;
mfc8316c->i2cData.writeBuffer[2] = controlWord & 0xFF;

// Build Data Word
mfc8316c->i2cData.writeBuffer[3] = (data >> 24) & 0xFF;
mfc8316c->i2cData.writeBuffer[4] = (data >> 16) & 0xFF; 
mfc8316c->i2cData.writeBuffer[5] = (data >> 8) & 0xFF;
mfc8316c->i2cData.writeBuffer[6] = data & 0xFF;

// Write I2C output buffer on the bus
mfc8316c->i2cData.writeLength = 7;

  • Hello Jean, 

    Thanks for reaching out. Could you confirm if the register read is matching the value you tried to set?

    I succeeded in doing the following : 

    1. Read a register content
    2. Write new content to that register
    3. Readback that new value from the register

    What is the behavior you are monitoring here?

    Therefore, I believe my implementation is fine. However, the change is never effective. Meaning, it is not reflected on the chips behavior. 

    Regards,
    Sachin S

  • Here is an example for trying to change the DIGITAL_SPEED_CTRL bit in ALGO_DEBUG1 register. 

    1. On Power-on, read the register 0x000000EC register, result : 0x00000000
    2. When setting the SPEED pin high, the driver tries to drive the motor at 100% with default config, which raises an error. This is the expected behavior in this case, as the default config cannot allow to drive the motor properly
    3. A Fault is raised
    4. To clear the fault, I attempt to set the CLR_FLT bit in the register ALGO_CTRL1: 0x000000EA is set to 0x20000000.
    5. The fault is not cleared. So I power-cycle to remove the fault.
    6. The DIGITAL_SPEED_CTRL bit is set in the ALGO_DEBUG1 register : the value 0x80000000 is set in the register 0x000000EC
    7. The register 0x000000EC is read back, the value 0x80000000 is found indeed.
    8. So the speed control should be  through I2C, and setting the speed pin to high should have no effect. 
    9. SPEED pin is set to high, the same behavior as 2. is seen. Therefore, the change in ALGO_DEBUG1 had no effect. 

    This is observed across the board. I used Motor Studio on the AEVM board to tune the parameters so the motor works well. I then export a json with the register values and use it to set all writable registers on my custom board. There is no effect, the motor behaves just like on the AEVM board with the default register values on startup. 

  • Hi Jean,

    Looks like the fault is making the device behave in an unusual way here. Could you tell me the FAULT code by reading the Fault Status registers.

    Regards,

    Sachin S

  • I'm unsure about that. On step 5, I can clear the fault by power cycling. Then, step 6 should ensure that step 8 will not cause a fault, but it does. The fault appears because step 6 did not successfully set the DIGITAL_SPEED_CTRL to I2C in register ALGO_DEBUG1 , which should have made the SPEED pin unsensitive to being set HIGH. 

    Besides, lets say I keep the SPEED pin low to avoid triggering any fault. I am still unable to change the speed via I2C, after setting all the registers as per the JSON file exported from MotorStudio and reading them back to confirm they contained the right value. 

    As mentioned earlier in the thread, I have been able to program the driver on my custom board by injecting the I2C signal from the AEVM board in my custom board. So the issue is not hardware.

    I measured the I2C signal of the AEVM board and found one significant discrepancy: the CLK frequency is about 350kHz, whereas mine is 10kHz. I used such low frequency because the I2C peripheral of my ATSAMD MCU has no parameter for inter-byte delay. I know you require 100us of inter-byte delay, so instead of sending bits at 350kHz with 100us delay between bytes, I send 10kHz bits and the 100us delay is built in. 

    Could that be the issue ? 

  • Hi Jean,

    Thanks for the detailed explanation. Could you let me know if the below points are correct with respect to the problem you are facing:

    1. The I2C from EVM plugged into your custom board works fine, but your own I2C implementation on the board does not work.

    2. The I2C from your custom board seems to be able to write to the registers (confirmed by I2C read back of the same register). But the written value seems to not take effect (from your point 6 to 9 in your experiments)

    Please do confirm the above points, 

    -------------------------------------------------------------------------------

    I know you require 100us of inter-byte delay, so instead of sending bits at 350kHz with 100us delay between bytes, I send 10kHz bits and the 100us delay is built in. 

    Could that be the issue ? 

    I need to check on this with the team. Could you try writing through ATSAMD MCU and reading the registers back through the EVM's I2C? Want to check if the write through ATSAMD MCU is incomplete.

    Regards,
    Sachin S