以下是ti提供的TIMERA例程;
// MSP-FET430P140 Demo - Timer_A, Toggle P3.4, CCR0 Cont. Mode ISR, DCO SMCLK
//
// Description: Toggle P3.4 using software and TA_0 ISR. Toggles every
// 50000 SMCLK cycles. SMCLK provides clock source for TACLK.
// During the TA_0 ISR, P3.4 is toggled and 50000 clock cycles are added to
// CCR0. TA_0 ISR is triggered every 50000 cycles. CPU is normally off and
// used only during TA_ISR.
// ACLK = n/a, MCLK = SMCLK = TACLK = default DCO ~800kHz
//
// MSP430F149
// ---------------
// /|| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P3.4|-->LED
//
// Dasheng
// LiTian Electronic Inc.
// Feb 2008
// Built with IAR Embedded Workbench Version: 3.42A
//******************************************************************************
#include <msp430x14x.h>
#include "BoardConfig.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BoardConfig(0xb8); //关闭数码管、流水灯和电平转换
P3DIR |= BIT4; // P3.4 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 2000000;
TACTL = TASSEL_2 + MC_2; // SMCLK, contmode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P3OUT ^= BIT4; // Toggle P3.4
CCR0 += 2000000; // Add Offset to CCR0
}
我就在iar上运行了,然后用示波器在p3.4口测试,可是尼玛这是什么问题?明明该是方波啊???是示波器有问题还是周围信号有干扰?下图这是哪门子波型?求大神帮小弟解答问题原因及解决措施。
此帖出自
小平头技术问答
一周热门 更多>