Main Content

enablePWM

Enable PWM pin

Add-On Required: This feature requires the MATLAB Support Package for BeagleBone Black Hardware add-on.

Description

enablePWM(bbb, pin_name) enables the PWM pin, pin_name.

example

Examples

collapse all

Enable PWM pin P9_14 (PWM1A)and set duty cycle, frequency, and voltage.

bbb = beaglebone();
enablePWM(bbb, 'P9_14')
writePWMDutyCycle(bbb, 'P9_14', 0.5)
writePWMFrequency(bbb, 'P9_14', 2000)
writePWMVoltage(bbb, 'P9_14', 1.5)

The result is a square wave with 50% duty cycle, a frequency of 2000 hertz, and a voltage varying from 0 V (low) and 1.5 V (high).

Input Arguments

collapse all

BeagleBone Black connection created using beaglebone, specified as an object.

Name of output pin.

PWMs PWM0A and PWM0B share pins with SPI 0 and serial port 2.

Alternative PWM fanouts PWM0A, PWM0B, PWM1A, PWM1B, PWM2A, and PWM2B share pins with HDMI, which is enabled by default. Use showPins to view the current pin usage. If HDMI is enabled, you cannot enable these pins using enablePWM. For information on how to disable HDMI, see the BeagleBone Black hardware documentation.

Example: 'P9_14'

Data Types: char

Version History

Introduced in R2015a