1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Vi điều khiển và ứng dụng OutputCompare

32 336 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 32
Dung lượng 1,71 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Các chế độ hoạt độngSingle compare match mode, Dual compare match mode generating either one output pulse or a sequence of output pulses, Pulse Width Modulation PWM mode... Single com

Trang 1

Output Compare

Chuyên đề II

Vi điều khiển và ứng dụng

Trang 2

OC with DsPIC

2

Trang 3

Chi tiết

3

Trang 4

Chức năng

4

Trang 5

Các chế độ hoạt động

Single compare match mode,

Dual compare match mode generating either one output pulse or a sequence of output pulses,

Pulse Width Modulation (PWM) mode

5

Trang 6

Single compare match

OCx pin is high, initial state is low, and interrupt is generated,

OCx pin is low, initial state is high, and interrupt is generated,

State of OCx pin toggles and interrupt is generated

6

Trang 7

OCx pin is high control bits OCM<2:0> are set to 001

7

Trang 8

OCx pin is low

OCM<2:0> are set to 010

8

Trang 9

Single compare match, pin OCx toggles

OCM<2:0> areset to 011

9

Trang 10

Ví dụ

10

Trang 11

Dual compare match

mode

single pulse and an interrupt request,

a sequence of pulses and an interrupt request

control bits OCM<2:0> are set to 100 or 101

11

Trang 12

Single output pulse at pin Ocx

OCM<2:0> are set to 100

12

Trang 13

Sequence of output pulses at pin Ocx

control bits OCM<2:0> are set to 101

13

Trang 14

Ví dụ

14

Trang 15

The Pulse Width

Trang 16

PWM mode without fault protection input

 Set the PWM period by writing to the selected

timer period register, PRy.

 Set the PWM duty cycle by writing to the OCxRS register.

 Write the OCxR register with the initial duty cycle.

 Enable interrupts for the selected timer.

 Configure the output compare module for one of two PWM operation modes by writing 100 to

control bits OCM<2:0> (OCxCON<2:0>).

 Set the TMRy prescale value and enable the

selected time base.

16

Trang 17

PWM mode with fault

protection input pin

Input pin OCxFA for the output compare

Trang 18

PWM period and duty

Calculation of the PWM period for a microcontroller having

a 10MHz clock with x4 PLL, Device clock rate is 40MHz The instruction clock frequency is FCY=FOSC/4, i.e

10MHz Timer 2 prescale setting is 4 Calculate the PWM period for the maximum value PR2=0xFFFF=65535.

TPWM = (65535+1) x 0.1µs x (4) = 26.21 ms, i.e fPWM = 1/TPWM = 38.14 Hz.

18

Trang 19

PWM duty cycle

If the duty cycle register,OCxR, is loaded

with 0000, the duty cycle is zero and pin OCx will remain low throughout the PWM period

If the duty cycle register is greater that PRy, the output pin OCx will remain high

throughout the PWM period (100% duty cycle)

If OCxR is equal to PRy, the OCx pin will be high in the first PWM cycle and low in the subsequent PWM cycle

19

Trang 20

Ví dụ

20

Trang 21

Mạch D/A

21

Trang 22

Ví dụ sóng vuông

22

Trang 23

Ví dụ sóng hình thang

23

Trang 24

Sóng hình sin

24

Trang 25

A second order filter

25

Trang 26

Ví dụ ứng dụng

26

Trang 27

Circular buffer

27

Trang 28

Circular buffer

28

Trang 29

Circular Buffer

29

Trang 30

Phương pháp hoạt động

Difficulites

30

Trang 31

Xử lý lỗi

Always Keep One Slot Open

Use a Fill Count

Read / Write Counts

31

Trang 32

Ví dụ

32

Ngày đăng: 30/12/2015, 18:05

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w