小弟覺得是timer可能哪裡有問題 請各位大家指教
#include "msp430x54xA.h"
int temp,temp1,x9,x10,x11,x12,out1,xx2,y9,y10,y11,y12,out2,yy2,out3,i,null;
#define Num_of_Results 8
volatile unsigned int A0results[Num_of_Results];
volatile unsigned int A1results[Num_of_Results];
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_8; // Turn on ADC12_A, extend sampling time
// to avoid overflow of results
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = ADC12INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = ADC12INCH_1+ADC12EOS; // ref+=AVcc, channel = A1
//ADC12IE = BIT1; // Enable ADC12IFG.3
ADC12CTL0 |= ADC12ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start conversion - software trigger
//------------------------------------------//
//P1DIR |= 0x01; // P1.0 output
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 3-1;
TA1CTL = TASSEL_2 + MC_1 + TACLR; // ACLK, upmode, clear TAR
//------------------------------------------//
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
//UCA0CTL0 |= UCMST+UCSYNC+UCCKPH+UCMSB; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 9; // 1MHz 115200 (see User's Guide)
UCA0BR1 = 0; // 1MHz 115200
UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, enable interrupts
__no_operation(); // For debugger
}
// Timer A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
temp = ADC12MEM0;
temp1 = ADC12MEM1;
x9 = temp >> 8;
y9 = temp1 >> 8;
out1 = temp-(x9*256);
out2 = temp1-(y9*256);
out3 = (y9*16)+x9;
//while (!(UCA0IFG&UCTXIFG));
UCA0TXBUF = out1;
while (!(UCA0IFG&UCTXIFG));
UCA0TXBUF = out2;
while (!(UCA0IFG&UCTXIFG));
UCA0TXBUF = out3;
}
此帖出自
小平头技术问答
AD采用率的話,我想應該可以用的
主要是UART用來傳輸
我設定的TIMER每秒已經超過4萬點可是卻無法到達,實際收到的點數只有1萬2左右
一周热门 更多>