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.

Masking error in SelectI2CInstance

File: starterware/bootloader/src/armv7a/am335x/bl_platform.c,
Function: void SelectI2CInstance(unsigned int i2cInstance)

I believe there is a masking error in this function. My understanding of the function is that it tries to set/clear bit 4 (SR_CTL_I2C_SEL) and leave the rest of the bits unchanged.

Current Code:

/* Modify reg value */

i2cInstance = (dataFromSlave[0] & PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL) |
(i2cInstance << PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_SHIFT);

What the function actually does is that it can set bit 4 (but not clear it) and it clears the other bits in the register.

Corrected Code:

/* Modify reg value */
i2cInstance = (dataFromSlave[0] & (~PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL)) |
(i2cInstance << PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_SHIFT);

Regards
Fredrik