Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

yefj

Advanced Member level 3
Advanced Member level 3
Joined
Sep 12, 2019
Messages
702
Helped
0
Reputation
0
Reaction score
2
Trophy points
18
Activity points
3,870
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
 

Attachments

  • 1676890319096.png
    1676890319096.png
    9 KB · Views: 20

KlausST

Super Moderator
Staff member
Advanced Member level 7
Joined
Apr 17, 2014
Messages
23,269
Helped
4,741
Reputation
9,503
Reaction score
5,127
Trophy points
1,393
Activity points
154,156
Hi,

this [ | ] is the OR operator
this [ << ] is the shift left operator

so doing
Code:
data = a << a_shift
     | b << b_shift

... you have four variables.
Example: Let´s say:
a = 1 = 0b00000001
a_shift = 2
b = 3 = 0b00000011
b_shift = 4

so a = 0b00000001 shifted 2 bits left becomes 0b00000100
and b = 0b00000011 shifted 4 bits left becomes 0b00110000

now do:
0b00000100 OR 0b00110000 to get 0b00110100

Klaus
 

betwixt

Super Moderator
Staff member
Advanced Member level 7
Joined
Jul 4, 2009
Messages
15,794
Helped
5,087
Reputation
10,199
Reaction score
4,950
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
133,759
Sorry for duplicating Klaus. The idea is to build a selection of bits but using the bit names rather than a number. The value of cmuClock is the state of bits selected by the named amount shifted the named '_POS' places.

Brian.
 

yefj

Advanced Member level 3
Advanced Member level 3
Joined
Sep 12, 2019
Messages
702
Helped
0
Reputation
0
Reaction score
2
Trophy points
18
Activity points
3,870
Hello Brian, Regarding the prescaler setting, i am using the register called High Frequency Clock Prescaler Register shown bellow.
i and trying to understand the logic of this register.
we have bits 8:12 which define the prescaler for HFCLK
They say presc is clock divition factor of PRESC+1
I cant understand this line if i want to prescal my frequence by 4 what values should i write for 8:12 bits in CMU_HFPRESC?
Thanks.
page 301



1676922869901.png


1676924735493.png
 

Attachments

  • 1676915460198.png
    1676915460198.png
    53.2 KB · Views: 17
  • 1676922565060.png
    1676922565060.png
    91.7 KB · Views: 20
  • 1676923058271.png
    1676923058271.png
    17.4 KB · Views: 20

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top