Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Realization of PWM Pulse count based on i.MX6UL

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Scope of application

This document introduces the basic implementation principle of PWM pulse counting based on i.MX6UL.

two。 Customer requirements 2.1 basic requirements

The basic requirement is to use PWM to output pulse waveforms with fixed frequency on i.MX6UL, and strictly control the number of pulses at that frequency. The application program calls the system interface to set the frequency of PWM output and the number of pulses output, and then PWM starts the pulse output. When the specified number of pulses is output, the application program is prompted to interrupt. At this point, the application again sets the latest PWM output frequency and the number of pulses, and cycles back and forth.

2.2 Parameter requirements

PWM frequency range: minimum 0Hz, maximum 25KHz

Count range: minimum 0, maximum 60000.

3. Brief introduction of principle

Because the PWM pulse output of i.MX6UL does not have the counting function itself, the combination of PWM+EPIT and PWM+EPIT is adopted.

EPIT (Enhanced Period Interrupt Timer) is a high precision periodic interrupt timer implemented by i.MX6UL, which uses the same clock source as PWM.

The basic idea is: when the application sets the PWM count value, starts the PWM output, converts the PWM count value into the timing period of EPIT, and starts the EPIT timing, when the timing period arrives, there is an interrupt, and the PWM output is disabled in the EPIT interrupt. At this time, the number of PWM pulse output should also reach the number of theoretical output.

3.1 user invocation process

The user invocation process is shown in figure 3-1.

Figure 3-1 user call flow

3.2 the ControlLib library implements 3.2.1 ControlOpen operations

Open PWM devices, EPIT devices, and set the default frequency for PWM devices and EPIT to work. Associate the PWM device with the EPIT device so that the corresponding PWM pulse output can be disabled in the EPIT interrupt.

3.2.2 ControlClose operation

Turn off the PWM device, EPIT device.

3.2.3 ControlSet operation

According to the following formula, according to the PWM frequency and count value set by the user, it is converted to the value of EPIT timing.

Then set the frequency of PWM work, start the PWM output; set the EPIT timing time, start EPIT timing.

3.2.4 ControlEventWait operation

Call the interface provided by the EPIT device, blocking the interrupt waiting for the timer to expire.

3.3.The effective range of parameters 3.3.1 PWM frequency range

The maximum frequency of PWM output is 50KHz and the minimum is 25Hz.

The PWM duty cycle defaults to 50%. Currently, adjustment is not supported.

3.3.2 count valid range

The theoretical maximum of PWM pulse count is 0xFFFFFFFF, but the count value Count is actually restricted by the following relations:

Freq is the output frequency actually set by PWM. When Freq decreases, the maximum countable value of Count decreases.

4. Test result

When setting the 50KHz frequency and output 20 times, the oscilloscope catches the waveform shown in figure 4-1.

Figure 4-1 50KHz, output 20 times

When the 25KHz frequency is set and output 33 times, the oscilloscope catches the waveform shown in figure 4-2.

Figure 4-2 25KHz, output 33 times

When setting the 10KHz frequency and output 60 times, the oscilloscope catches the waveform shown in figure 4-3.

Figure 4-3 10KHz, output 60 times

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report