# question regarding this C operations

#### yefj

##### Full Member level 1
Hello, i cant see the link between the comment about TIM0_CC0 in the actual code bellow?
and what is the meaning of |= in this code?
Thanks.

Code:
  // Set route to Location 15 and enable
// TIM0_CC0 #15 is PC10
TIMER0->ROUTELOC0 |=  TIMER_ROUTELOC0_CC0LOC_LOC15;
TIMER0->ROUTEPEN |= TIMER_ROUTEPEN_CC0PEN;

#### betwixt

##### Super Moderator
Staff member
Standard C language.

The '|' means logic OR.
The '=' means 'becomes' in this context.

'|=' means the left value becomes itself OR'ed with the right value.

Without knowing what processor your code is for we can't comment on what it actually does in the program.

Brian.

Staff member

#### yefj

##### Full Member level 1
Hello My Board is EFR32FG14
regarding the -> i read its a pointer but i cant see the logic in here
it loks like -> means sub member.

#### betwixt

##### Super Moderator
Staff member
regarding the -> i read its a pointer but i cant see the logic in here
It is a pointer, usually to a structure member.

Brian.

#### yefj

##### Full Member level 1
if -> is a pointer |= is OR then what is the logical meaning of such line?

TIMER0->ROUTELOC0 |= TIMER_ROUTELOC0_CC0LOC_LOC15;

Thanks.

#### ZASto

Try to find a book "C for dummies"

#### yefj

##### Full Member level 1
We are ORing in a value to a register. My processor has a TIMER0 with a register ROUTELOC0. It likely has a bit that is "CC0LOC_LOC15"

Why Are we using OR for Setting route to Location?

#### KlausST

##### Super Moderator
Staff member
Hi,

Why Are we using OR for Setting route to Location?
How else?

But wait. The benefit of OR is, that all other bits remain unchanged..

Let´s assume you have a register of unknown value: 0b xxxx xxxx
now you want to set bit0 and bit 3 (0b 0000 1001)
then simply OR both registers and get: 0b xxxx 1xx1

****
But yes, find a book for basics... a forum can´t replace school and reading books.

Klaus

#### c_mitra

My processor has a TIMER0 with a register ROUTELOC0. It likely has a bit that is "CC0LOC_LOC15"
You need to work out in longhand; the time shall be well invested.

TIMER0 is a register within the processor that has been defined in some header files. The content of this register is described by a set of bits LOC0 to LOC15.

How to set these values? This is the routine way in C to set some 16 bit registers to some defined state. There may be other ways (sure!) but this is short and clear.

yefj

### yefj

points: 2

#### c_mitra

You have added (INCLUDE files) a processor specific header file. Take a look at the inside (do not change anything) and look for a variable TIMER0.

These system variables are very special: they are given only a location. It seems your TIMER0 is a 16 bit register. But this variable has to go to a fixed place. Hence TIMER0 is actually an address (one of the several registers).

Now you cannot manipulate TIMER0 like you can (other variables); it is a pointer to a particular location (yes, registers are just memory locations for the processor). See the memory map model for the particular processor.

Similarly, ROUTELOC0 and other variables are actually bit values but stored into an int. Please check with the program flow. There must not be any declaration for these variables. They are defined in the manual.