SERCOM Peripherals not updating (ATSAMD10D13AS)

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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?

This topic has a solution.
Last Edited: Tue. Mar 1, 2022 - 08:06 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

From the register description section in the data sheet:

Some registers are enable-protected, meaning they can only be written when the I2C is disabled. Enable-protection is denoted by the Enable-Protected property in each individual register description.

/Lars