I'm confused with register wrting method by compound assignment and/or pointer because I don't know where are some of the values come from.
Example 1
REG_PMC_PCER1 |= PMC_PCER1_PID36; // Enable PWM - Peripheral Identifiers 36
- This works the same as
REG_PMC_PCER1 = (1<<4)
REG_PMC_PCER1
is not readable, so|=
operator shouldn't work.- What is
PMC_PCER1_PID36
? Is the some sort of bit mask defined in the IDE ?
Example 2
PMC->PMC_PCER0 |= PMC_PCER0_PID13; // PWM controller power ON
- This works the same as
REG_PMC_PCER0 = (1<<13)
- This is similar to Example 1 but there is pointer
PMC
. Why it's needed ? IfPMC_PCER0_PID13
is a bit mask thenREG_PMC_PCER0
need not indexing.
So my questions are:
- Why compound assignment works on write-only registers ?
- Where are those constants (
PMC_PCER1_PID36
,PMC
,etc.) defined ?
Thanks in advance !