I wanted to put the MCU in standby mode and wake it up with I2C (on address match). Everything works fine but there is a weird error that occurs if I set CTRLA values separately. If I write:
I2C_SERCOM->I2CS.CTRLA.reg = SERCOM_I2CS_CTRLA_ENABLE | SERCOM_I2CS_CTRLA_MODE_I2C_SLAVE |SERCOM_I2CS_CTRLA_RUNSTDBY;
everything works and the debugger shows value: 146 for I2C_SERCOM->I2CS.CTRLA.reg. However if I write:
I2C_SERCOM->I2CS.CTRLA.reg = SERCOM_I2CS_CTRLA_ENABLE | SERCOM_I2CS_CTRLA_MODE_I2C_SLAVE; I2C_SERCOM->I2CS.CTRLA.reg |= SERCOM_I2CS_CTRLA_RUNSTDBY;
the value stays 18 like the second line never happened the same goes for:
I2C_SERCOM->I2CS.CTRLA.reg = SERCOM_I2CS_CTRLA_ENABLE | SERCOM_I2CS_CTRLA_MODE_I2C_SLAVE; I2C_SERCOM->I2CS.CTRLA.bit.RUNSTDBY = 1;
I understand that the debugger can cause many weird things to happen, so I tried to run the code directly and print the values in a terminal and the same thing happens. Any ideas on why this is happening?