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.

question regarding this C operations

Status
Not open for further replies.

yefj

Advanced Member level 5
Advanced Member level 5
Joined
Sep 12, 2019
Messages
1,505
Helped
1
Reputation
2
Reaction score
5
Trophy points
38
Activity points
9,114
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;
 

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.
 

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.
 

if -> is a pointer |= is OR then what is the logical meaning of such line?

TIMER0->ROUTELOC0 |= TIMER_ROUTELOC0_CC0LOC_LOC15;

Thanks.
 


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?
 

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
 

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.

Read about bit manipulations of registers- the manual is a good source and all the variables are defined in the header files. Take a look at the header files to learn more.
 
  • Like
Reactions: yefj

    yefj

    Points: 2
    Helpful Answer Positive Rating
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.

You need to read something about the linker: how does it handle the timer registers.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top