Chapter 9

Output Compare

Abstract

This chapter describes the PIC32’s output compare peripheral, which is used to generate pulse-width modulation (PWM) pulse trains. A PWM pulse train, when used with an H-bridge, can control the speed and direction of a motor. A PWM signal can also be used to control the brightness of an LED or low-pass filtered to generate an analog output. The special function registers controlling the output compare peripheral are explained and sample code is given.

Keywords

Output compare

Pulse-width modulation (PWM)

Analog output

Duty cycle

RC filter

Low-pass filter

The output compare (OC) peripheral sets the state of an output pin based on the value of a timer. Output compare can be used to generate a single pulse of ...

Get Embedded Computing and Mechatronics with the PIC32 Microcontroller now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.