title: C bitwise OR is returning incorrect value
body: <p>I have a void function that's supposed to set the first 8 bits of a 32-bit register. However, it keeps returning incorrect values (only powers of 2).</p>
  <pre><code>void ugvPwm_setSpeed(ugv_pwm *InstancePtr, u8 spd_val)
  {
      u32 reg_read;
      u32 spd_sel;
      reg_read = MOTORPWM_mReadReg(InstancePtr-&gt;RegBaseAddress,
                                  MOTORPWM_S00_AXI_SLV_REG0_OFFSET); // read original register value
      //
      xil_printf(&quot;\r\n\nugvPwm_setSpeed: reg0 = %x\r\n&quot;, reg_read);
      xil_printf(&quot;ugvPwm_setSpeed: duty = %x\r\n&quot;, (u32) spd_val);
      spd_sel = reg_read | (u32) spd_val;                        // bitwise OR in new value; PROBLEM HERE!
      xil_printf(&quot;ugvPwm_setSpeed: new reg0 (reg0 | duty) = %x\r\n\n&quot;, spd_sel);
      //
      InstancePtr-&gt;speedSelect = spd_val;
      MOTORPWM_mWriteReg(InstancePtr-&gt;RegBaseAddress, MOTORPWM_S00_AXI_SLV_REG0_OFFSET, spd_sel);
  }
  </code></pre>
  <p>u32 and u8 on my platform correspond to unsigned int and unsigned char respectively. I've tried it using onlinegdb using unsigned int and unsigned char and it works perfectly. The output on my platform is shown below:</p>
  <pre><code>ugvPwm_setSpeed: reg0 = 300
  ugvPwm_setSpeed: duty = 1
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 301
  ugvPwm_setSpeed: expected               = 301
  
  ugvPwm_setSpeed: reg0 = 301
  ugvPwm_setSpeed: duty = 2
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 303
  ugvPwm_setSpeed: expected               = 302
  
  ugvPwm_setSpeed: reg0 = 303
  ugvPwm_setSpeed: duty = 3
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 303
  ugvPwm_setSpeed: expected               = 303
  
  ugvPwm_setSpeed: reg0 = 303
  ugvPwm_setSpeed: duty = 4
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 307
  ugvPwm_setSpeed: expected               = 304
  
  ugvPwm_setSpeed: reg0 = 307
  ugvPwm_setSpeed: duty = 5
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 307
  ugvPwm_setSpeed: expected               = 305
  
  ugvPwm_setSpeed: reg0 = 307
  ugvPwm_setSpeed: duty = 6
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 307
  ugvPwm_setSpeed: expected               = 306
  
  ugvPwm_setSpeed: reg0 = 307
  ugvPwm_setSpeed: duty = 7
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 307
  ugvPwm_setSpeed: expected               = 307
  
  ugvPwm_setSpeed: reg0 = 307
  ugvPwm_setSpeed: duty = 8
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 30F
  ugvPwm_setSpeed: expected               = 308
  
  ugvPwm_setSpeed: reg0 = 30F
  ugvPwm_setSpeed: duty = 9
  ugvPwm_setSpeed: new reg0 (reg0 | duty) = 30F
  ugvPwm_setSpeed: expected               = 309
  </code></pre>