title: Register Synchronization
body: <p>What is meant by register synchronization in micro-controllers?</p>
  
  <p>ATMEL SAM D20 boards use an ARM Cortex M0, in there framework they use two methods of setting/clearing output pins on the board. First one is <strong>OUTSET.reg</strong> which uses shift operation to build up a mask, then that mask is used with a logical operator to set or clear a specific bit. The second one is <strong>OUTSET.bit.OUTSET</strong> which according to the header files is used to set a specific bit (specific pin). I tried searching for the difference between the two and all I could find was a forum response </p>
  
  <blockquote>
    <p>Because for registers that need synchronization manipulating individual bits is risky and you can't do multiple bits in a row without synchronizing each and every of them. And that's just silly.</p>
  </blockquote>
  
  <p>Here is a snippet from ATMEL port.h header file</p>
  
  <pre><code>typedef union {
    struct {
      uint32_t OUTSET:32;   //bit:  0..31  Port Data Output Value Set         
    } bit;                  //Structure used for bit  access                  
    uint32_t reg;           //Type      used for register access              
  } PORT_OUTSET_Type;
  </code></pre>