understanding meaning of | << opertation for GPIO clock in EFR32FG14

Thread Starter

yef smith

Joined Aug 2, 2020
572
Hello,Inside CMU_ClockEnable(cmuClock_GPIO, true); we have cmuClock_GPIO parameter which is defined inside
em_cmu.h file and its definition is shown in code bellow.
What is the logical meaning of such expression?
how do i know a what register we write the value?

i know that | is "or" << is shift

I have tried to read and we shift at no prescale register some PRESC REG POS.what is the logical thing they are doing?
Thanks.


Code:
#if defined(CMU_HFBUSCLKEN0_GPIO)
  /** General-purpose input/output clock */
  cmuClock_GPIO = (CMU_NOPRESC_REG << CMU_PRESC_REG_POS)
                  | (CMU_NOSEL_REG << CMU_SEL_REG_POS)
                  | (CMU_HFBUSCLKEN0_EN_REG << CMU_EN_REG_POS)
                  | (_CMU_HFBUSCLKEN0_GPIO_SHIFT << CMU_EN_BIT_POS)
                  | (CMU_HFBUS_CLK_BRANCH << CMU_CLK_BRANCH_POS),
#endif
 

Papabravo

Joined Feb 24, 2006
20,399
They are building up a word from small bit strings that are shifted just the right number of bits so that all the values are preserved and they end up in the correct location withing the larger word. Take the following example:
1 << 5 | 2 << 3 | 3 << 0​
1 << 5 = 0x20​
2 << 3 = 0x10​
3 << 0 = 0x03​
Or them all together and you get 0x33. You could also use the addition operator or the XOR operator and get the same result.​
 
Top