模拟量输入 p1.0/a0
输出pwm p2.0/ta1.0
参考电压 p1.4
写的一段程序 但是检测不到pwm输出 求大神指点
#include "MSP430G2553.h"
const unsigned int table[1024]={电压值对应不同的周期
};
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
ADC10CTL1 = CONSEQ_2+ADC10SSEL_2; // TA0 trigger
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + SREF_2 ;
ADC10DTC1 = 0x01;
ADC10AE0 |= 0x01;
ADC10CTL0 |=ENC+ADC10SC;
while(1)
{
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = 0x200;
TACTL |= TASSEL1+TACLR;
TACCR0=table[ *(int *)0x200];
TACCTL1=OUTMOD_7;
TACCR1= table[ *(int *)0x200]/2;
P2DIR |= 0x01;
P2SEL |= 0x01;
TACTL |=MC_1;
ADC10CTL0 |= ENC; // Sampling and conversion ready
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, enable interrupts
// Toggle P1.0 using exclusive-OR
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
|