What do you mean by parsing this code?
God says: Select Prescaler 0
Why?
God said: Because the experiment selected is Timer1, in the Prescaler 0;
If you choose Timer4, how do you write this code?
First look at the tcfg0 in the selection Prescaler 1, look at the tcfg1 inside the timer4, and select the corresponding MUX
Summary: When initializing a register, the Register table is the first, the Register table may be divided into a number of "bits", which we need to give which bit to write the value (this value is the corresponding function to write).
Divider 1:
The corresponding code:
① Select Prescaler 1:
Writel (Readl (&pwm_timer->tcfg0) | 0xFF << 8, &pwm_timer->tcfg0);
The book shows that the value range of Prescaler is 1~255 (God tells me that the higher the value, the greater the frequency, the faster the buzzer rings).
So here we don't have to care what the value is, we just need to make this value not the initial value, and in TCFG0 [15:8] This place, move left 8, you can reach this place;
② Select MUX4, frequency is 1/16:
, can know MUX4 corresponds to tcfg1[19:16], select frequency is 1/16, corresponds to bits 0100, can let 0x4 << 16, get.
But in order for [15:0] to not work, give them all assigned value 1 (here is not very clear, own guess, probably is this!) ), i.e. 1111,1111,1111,1111
Can be shifted by 0xf to the left 16 bits, and reversed, in with [0x4 << 16] take with &
The code is:
Writel ((Readl (&PWM_TIMER->TCFG1) & ~ (0xf<<16)) | (0x4<<16), &PWM_TIMER->TCFG1);
Writel (Readl (&pwm_timer->tcfg0) | 0xFF, &PWM_TIMER->TCFG0);