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;
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.
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.
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.