My requirements: collecting AC 50Hz signals, wave 64 points per week, sampling rate of Fs=50*32=1600; MCLK=SCLK=12MHz
Timer clock frequency =MCLK; sampling timer timing length =12000000/1600=7500;
In the timer interrupt program, start the ADC conversion, and reverse the P1.3 pin status to monitor the timer length, to get the frequency output =800Hz, indicating that the timer is set correctly
void TIMER_A_INIT(void) { u16 t; //CCR0 = 7500; t=12000000/(50*32); CCR0 = t; TACTL = TASSEL_2 + TACLR+ MC_1; CCTL0 = CCIE; } #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { SD24CCTL0 |= SD24SC; P1OUT ^= BIT3; ; } void sd24_a_init(void) { u16 i; SD24CTL = SD24SSEL_1+SD24DIV_2+SD24XDIV_1+SD24REFON; // 1.2V ref, SMCLK Fadc=12000000/(4*3)=1000000 SD24INCTL0 = SD24INCH_0+SD24GAIN_4+SD24INTDLY_3; // Interrupt on 1rd sample SD24CCTL0 = SD24SNGL+SD24DF+SD24OSR_256+SD24IE; //单次转换模式,双极性模式补码输出,过采样256,,中断使能 for (i = 0; i < 0x4000; i++); // Delay for 1.2V ref startup index=0; } #pragma vector=SD24_VECTOR __interrupt void SD24AISR(void) { u8 i; if(SD24IV==SD24IV_SD24MEM0) { ad_buf[index] = SD24MEM0; if (++index == samplebuftime) { for(i=0;i<samplebuftime;i++) ad[i]=ad_buf[i]; index=0; } P1OUT ^= BIT4; } }
As set above, get the P1.4 pin output frequency =800 is correct. The sampling rate was 1600
But I read the AD sampling is wrong
Help me analyze where the problem is, thank you very much