大家好:
我们购买了M430F5438A几套开发板,希望进行FFT的开发!
采用两路正弦信号: a). 频率:1500HZ; 相位:0; 幅值:1V, 信号连接到P6.7,A7 ADC输入;
b). 频率:1500HZ; 相位:35度; 幅值:10mV,信号输入端口MIC(M1)信号连接到P6.5,A5 ADC输入—-内含运算放大器;
我们采用如下编程方式,请问:问题在哪?
初始化: AUDIO_PORT_OUT |= MIC_POWER_PIN;
AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
AUDIO_PORT_SEL |= MIC_INPUT_PIN;
P6OUT |= MIC_POWER_PIN;
P6OUT &= ~0x80;
P6DIR &= ~(MIC_INPUT_PIN + 0x80);
P6SEL |= 0x80;
UCSCTL8 |= MODOSCREQEN;
ADC12CTL0 &= ~ADC12ENC; // Disable conversions to configure ADC12
ADC12CTL0 = ADC12ON + ADC12SHT02 + ADC12MSC; // Configure ADC12 to sample a sequence of channels, once
ADC12CTL1 = ADC12SHP + ADC12CONSEQ_3 + ADC12SSEL_2 + ADC12SHS_3;
ADC12CTL2 = ADC12RES_2; // Select 12-bit resolution
ADC12MCTL0 = ADC12INCH_5;
ADC12MCTL1 = ADC12INCH_7|ADC12EOS;
ADC12CTL0 |= ADC12ENC; // Enable
ADC12IE = BIT0 + 0x80;
// Initialize Timer_B to be used as ADC12 trigger
TBCTL = TBSSEL_2 + TBCLR; // Use SMCLK as Timer_B source
TBCCR0 = 2047; // Initialize TBCCR0 (period register)
TBCCR1 = 2047 – 100; // Initialize TBCCR1 (ADC12 trigger)
TBCCTL0 = 0x0000;
TBCCTL1 = OUTMOD_7;
TBCCTL2 = 0x0000;
TBCCTL3 = 0x0000;
TBCCTL4 = 0x0000;
TBCCTL5 = 0x0000;
TBCCTL6 = 0x0000;
中断处理程序:
#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch (__even_in_range(ADC12IV, ADC12IV_ADC12IFG15))
{
case ADC12IV_NONE: break; // Vector 0: No interrupt
case ADC12IV_ADC12OVIFG: break; // Vector 2: ADC overflow
case ADC12IV_ADC12TOVIFG: break; // Vector 4: ADC timing overflow
case ADC12IV_ADC12IFG0: buffer_s[buf_index_s++] = ADC12MEM0;
buffer_s[buf_index_s++] = 0;
if (buf_index_s == 1024){
buf_index_s = 0;
__bic_SR_register_on_exit(LPM0_bits);
}
else if (buf_index_s == 512) {
__bic_SR_register_on_exit(LPM0_bits);
}
break; // Vector 6: ADC12IFG0
case ADC12IV_ADC12IFG1: // Vector 8: ADC12IFG1
buffer[buf_index++] = ADC12MEM1;
buffer[buf_index++] = 0; if (buf_index == 1024){
buf_index = 0;
__bic_SR_register_on_exit(LPM1_bits);
}
else if (buf_index == 512){
__bic_SR_register_on_exit(LPM1_bits);
} break;
case ADC12IV_ADC12IFG2: break; // Vector 10: ADC12IFG2
case ADC12IV_ADC12IFG3: break; // Vector 12: ADC12IFG3
case ADC12IV_ADC12IFG4: break; // Vector 14: ADC12IFG4
case ADC12IV_ADC12IFG5: break; // Vector 16: ADC12IFG5
case ADC12IV_ADC12IFG6: break; // Vector 18: ADC12IFG6
case ADC12IV_ADC12IFG7: break; // Vector 20: ADC12IFG7
case ADC12IV_ADC12IFG8: break; // Vector 22: ADC12IFG8
case ADC12IV_ADC12IFG9: break; // Vector 24: ADC12IFG9
case ADC12IV_ADC12IFG10: break; // Vector 26: ADC12IFG10
case ADC12IV_ADC12IFG11: break; // Vector 28: ADC12IFG11
case ADC12IV_ADC12IFG12: break; // Vector 30: ADC12IFG12
case ADC12IV_ADC12IFG13: break; // Vector 32: ADC12IFG13
case ADC12IV_ADC12IFG14: break; // Vector 34: ADC12IFG14
case ADC12IV_ADC12IFG15: break; // Vector 34: ADC12IFG14
}
}
Susan Yang:
user5274273 我们采用如下编程方式,请问:问题在哪?
请问您现在使用该代码是出现了什么问题?若是可以的话,请私信我完整代码,以供后续测试,谢谢
user5274273:
回复 Susan Yang:
谢谢!
我手机:18663723258;期待尽快联系
Susan Yang:
回复 user5274273:
所以您现在是编译错误还是功能错误?我这边尝试您的程序有一些编译错误
user5274273:
回复 Susan Yang:
我这边是功能错误!
好像经常进入ADC12IV_ADC12IFG0中断,即使没有数据输入!
进不了ADC12IV_ADC12IFG1中断。
user5274273:
回复 Susan Yang:
动作好快!
wait仅仅是一个死循环的标志!
希望P6.5(A5)的数据进入buffer[1024], 将来作FFT变换!
同时,P6.7(A7)的数据进入buffer_s[1024], 作FFT变换;实现“双通道”的同时工作
Susan Yang:
回复 user5274273:
您的ADC初始话部分有些问题,我结合例程测试了一下,可以进入ADC12IFG0中断(我测试时接的是P6.7)在hal_adc.c的case6 和case8分别加断点
建议您分别测试两个ADC通道,其中一个成功后再添加另一个
MSP-EXP430F5438_User_Experience.zip
user5274273:
回复 Susan Yang:
抱歉,这个压缩包不完整
user5274273:
回复 user5274273:
我使用IAR来编译的