Writel (Readl (&pwm_timer->tcfg0) | 0xFF, &PWM_TIMER->TCFG0);

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.