下面是源程序:#include <msp430xG43x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC12CTL0 = SHT0_2 + ADC12ON; // Set sampling time, turn on ADC12
ADC12CTL1 = SHP+ADC12SSEL_3; // Use sampling timer,ADC12clok=smclk;
ADC12IE = 0x01; // Enable interrupt
ADC12CTL0 |= ENC; // Conversion enabled
P6SEL |= 0x20; // P6.0 ADC option select
P3DIR |= 0xb0; // P5.1 output
P3OUT = 0x00;
DAC12_0CTL = DAC12IR + DAC12AMP_2; // Internal ref gain 1
DAC12_0CTL |= DAC12ENC; // 使能dac
for (;;)
{
ADC12CTL0 |= ADC12SC; // Sampling open
_BIS_SR(CPUOFF + GIE); // LPM0, ADC12_ISR will force exit
}
}
//ADC12 interrupt service routine
#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR (void)
{
DAC12_0DAT = ADC12MEM0;
_BIC_SR_IRQ(CPUOFF);
}
|