//
//
//+—–(0.9766us)———\——————>+
//TA0_ISRTA1ADC10_ISRTA0_ISRTA1
//—–+————+————+———–\——+————+—–>
//Enable ADCTrigger ADCDisable ADC
//and VrefCompare
//+-( >30us—>+
//
//
//MSP430G2x33/G2x53
//—————–
///||XIN|-
//| || 32kHz
//–|RSTXOUT|-
//||
//>—|P1.7/A7P1.0 |–> LED
//
//D. Dang
//Texas Instruments Inc.
//December 2010
//Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include“msp430g2553.h”
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;// Stop WDT
ADC10CTL1 = INCH_7 + SHS_1;// P1.7, TA1 trigger sample start
ADC10AE0 = 0x80;// P1.7 ADC10 option select
P1DIR |= 0x01;// Set P1.0 to output direction
TACCTL0 = CCIE;// Enable interrupt
TACCR0 = 32-1;// PWM Period
TACCTL1 = OUTMOD_3;// TACCR1 set/reset
TACCR1 = 2;// TACCR1 PWM Duty Cycle
TACTL = TASSEL_1 + MC_1;// ACLK, up mode
__bis_SR_register(LPM3_bits + GIE);// Enter LPM3, enable interrupts
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
ADC10CTL0 &= ~ENC;// ADC10 disabled
ADC10CTL0 = 0;// ADC10, Vref disabled completely
if (ADC10MEM < 0x88)// ADC10MEM = A7 > 0.2V?
P1OUT &= ~0x01;// Clear P1.0 LED off
else
P1OUT |= 0x01;// Set P1.0 LED on
}
// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void)
{
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;
ADC10CTL0 |= ENC;// ADC10 enable set
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/dongtai/257923.html