cancel
Showing results for 
Search instead for 
Did you mean: 

ST25DV64K Check MB_MODE failing

isaacseeto
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3
JL. Lebon
ST Employee

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.

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.

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.