pindir( portpin, PULSEOUT )

Configure Pulse Output Pin


Syntax: pindir( portpin, PULSEOUT )
Description: Configures a pin to be a pulse output
Parameters: portpin  Name of a portpin, Only certain pins are can be used for pulse outputs. This can be in the form Px_y. Where x is the port number, which can be 1 or 2, and y is the bit number which is between 0 and 7. (e.g. P2_3)
PULSEOUT Type name to configure pin as a Pulse output
Returns: Nothing
Related: pulse_enable()pulse_width()pulse_period(), pindir()


This command configures a pin to be a pulse output. The pulse outputs can only be used on certain output pins.

Pulse timer circuits are used to generate square wave signals on the output pins.  Use the pulse_enable() function command to enable a given pulse timer circuit. The pulse_enable () function must be used before the pulse_period() or pulse_width() functions. Use the pindir(pin, PULSEOUT) function to route the pulse signal onto an output pin.  See here for more details on the use of the pulse functions.

Most of the microcontroller chips have only one pulse circuit, so only timer 0 output is available for use.  But the largest MSP430G2553 has three pulse timers 0, 1, and 2.

The pulse output pin are enabled using the pindir() command. However the pulse outputs can only be used on certain output pins. The hardware pins that can be used for pulse outputs are limited as follows.

The timer 0 output can only be used on two pins P1_2, and P1_6.
The timer 1 output can only be used on two pins P2_1, and P2_2.
The timer 2 output can only be used on two pins P2_4, and P2_5.

For the largest MSP430G2553 chip the pulse_period() of timer 1 and timer 2 are the same.  Changing the period of timer 1 using the command  pulse_period(1, 1000) will also change the period of timer 2 output to 1000,  and changing the period of timer 2 using the command pulse_period(2,3000)  will also set timer 1 period to 3000.

Example:

pulse_enable(0)           # Enables the Pulse 0 circuit
pindir(P1_2, PULSEOUT)    # Enables the Pulse 0 output onto pin P1_2
pulse_period(0, 20000)    # Output a pulse that repeats every 20,000 clocks
pulse_width(0, 5000)      # Output a pulse that has a width of 5000 clocks

In this example the timer 0 circuit is enabled with the pulse_enable(0) command and pindir(P1_2, PULSEOUT)  command enables the timer 0 output onto to pin P1_2. The pulse_period(20000) command produces a pulse output  that repeats every 20000 clocks, and the pulse_width(5000) sets the width of the pulse to 5000 clocks.