?? msp430x11x1_ta_16.c
字號:
//*******************************************************************************
// MSP430x11x1 Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
//
// Description: This program generates two PWM outputs on P1.2,3 using
// Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
// period and the values in CCR1 and CCR2 the PWM duty cycles. Using ~800kHz
// SMCLK as TACLK, the timer period is ~640us with a 75% duty cycle on P1.2
// and 25% on P1.3.
// ACLK = na, SMCLK = MCLK = TACLK = default DCO ~800kHz.
//
// MSP430F1121
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.2/TA1|--> CCR1 - 75% PWM
// | P1.3/TA2|--> CCR2 - 25% PWM
//
// M. Buccini
// Texas Instruments Inc.
// Feb 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
//*****************************************************************************
#include <msp430x11x1.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x0C; // P1.2 and P1.3 output
P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 options
CCR0 = 512-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 384; // CCR1 PWM duty cycle
CCTL2 = OUTMOD_7; // CCR2 reset/set
CCR2 = 128; // CCR2 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
_BIS_SR(CPUOFF); // Enter LPM0
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -