Skip to main content
Explorer
September 19, 2024
Solved

ST25DV64K Check MB_MODE failing

  • September 19, 2024
  • 1 reply
  • 724 views

Hi, 

I was just wondering if someone could spot why my code could be failing when my CheckMBMode function is being called in my main loop. I am successfully opening a security session before reading and writing to the MB Mode register so I am unsure what I am doing wrong.

Code:

#define ST25DV_I2C_SYST_ADDRESS 0xAE

#define MB_MODE_ADDRESS 0x000D // MB_MODE register address (for enabling FTM)

// Function to read and check the status of MB_MODE (FTM status)

HAL_StatusTypeDef CheckMBMode(uint8_t *reg_value) {

// Read the MB_MODE register (1 byte, 8-bit register)

return HAL_I2C_Mem_Read(&hi2c1, ST25DV_I2C_SYST_ADDRESS, MB_MODE_ADDRESS, I2C_MEMADD_SIZE_16BIT, reg_value, 1, HAL_MAX_DELAY);

}

Thanks.

    This topic has been closed for replies.
    Best answer by isaacseeto

    Changing the I2C_MEMADD_SIZE_8BIT to 16BIT seemed to fix the error. 

    Both MB_MODE and Dynamic Ctrl are being set and read correctly now.

    1 reply

    ST Employee
    September 19, 2024

    Hello, 

    Nothing looks wrong in your code.

    Do you have any debug trace to share, or wo you know at which Byte your i2C command is NACK'ed ?

    Also, are the other I2C command working fine?

    Best regards.

    Explorer
    September 19, 2024

    I have found that the function doesn't get caught if I do not call my enable Dynamic Mailbox function.

    isaacseeto_2-1726740616693.png

    isaacseeto_3-1726740663521.png

     

    If this function is called the following occurs.

    In I2C Mem Read it goes to an error handler at the highlighted line:

    isaacseeto_1-1726740300965.png

    This is the error handler that it gets stuck in: 

    isaacseeto_0-1726740131526.png

    My set MB_MODE function does not seem to be working as the check function is not returning 0x01.

    Thanks again.

    isaacseetoAuthorAnswer
    Explorer
    September 20, 2024

    Changing the I2C_MEMADD_SIZE_8BIT to 16BIT seemed to fix the error. 

    Both MB_MODE and Dynamic Ctrl are being set and read correctly now.