Set Pulse Period
|Syntax:||pulse_period( pulse, clocks )|
|Description:||Sets the period of the timer pulse output, this is the repetition rate of the pulse output.|
|Parameters:||pulse||The number of the pulse circuit. This is a number 0, 1, or 2. Upto to 3 different pulse circuits are available. The number of pulse circuits available depends on the microcontroller chip. Note pulse 1 and 2 have the same period.|
|clocks||Sets the number of clocks for the pulse period . This is a 16bit integer number.|
|Related:||pulse_enable(), pulse_width(), pindir()|
This command sets the period or repetition rate for a pulse circuit.
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() 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(pin,PULSEOUT) 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.
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.