工具与软件:
您好!
我使用 MSP430FR6989开发板。 我设置了 P9.0至 P9.7的引脚、并且我想通过使用中断来获取这些值。 即使在调试时分别连接了引脚 GND 和3V3电压引脚、我得到的结果也介于700和890之间。 任何引脚上都没有变化。 我在这里共享测试代码。 我曾尝试更改基准电压(例如内部1.2V 或2V)、但仍未获得逻辑结果。 任何帮助都将受到赞赏。
此致。
#include <msp430.h> #include <stdint.h> volatile uint16_t adc_values[8]; volatile uint8_t adc_index = 0; void led_config(); void led_on(); void led_off(); void main(void) { WDTCTL = WDTPW + WDTHOLD; PM5CTL0 &= ~LOCKLPM5; ADC12CTL0 = ADC12SHT0_3 | ADC12ON; ADC12CTL1 = ADC12SHP | ADC12CONSEQ_1; ADC12CTL2 = ADC12RES_2; ADC12MCTL0 |= ADC12INCH_0 | ADC12VRSEL_0; ADC12MCTL1 |= ADC12INCH_1 | ADC12VRSEL_0; ADC12MCTL2 |= ADC12INCH_2 | ADC12VRSEL_0; ADC12MCTL3 |= ADC12INCH_3 | ADC12VRSEL_0; ADC12MCTL4 |= ADC12INCH_4 | ADC12VRSEL_0; ADC12MCTL5 |= ADC12INCH_5 | ADC12VRSEL_0; ADC12MCTL6 |= ADC12INCH_6 | ADC12VRSEL_0; ADC12MCTL7 |= ADC12INCH_7 | ADC12VRSEL_0; P9SEL0 |= 0xFF; P9SEL1 |= 0xFF; ADC12IER0 |= ADC12IE0 | ADC12IE1 | ADC12IE2 | ADC12IE3 | ADC12IE4 | ADC12IE5 | ADC12IE6 | ADC12IE7 ; while(1) { ADC12CTL0 |= ADC12SC | ADC12ENC; // ADC örnekleme ve dönüşümü başlat __delay_cycles(2000); __bis_SR_register(GIE); } } #pragma vector=ADC12_VECTOR __interrupt void ADC_ISR(void) { switch(__even_in_range(ADC12IV, ADC12IV_ADC12RDYIFG)) { case ADC12IV_ADC12IFG0: adc_values[0] = ADC12MEM0; break; case ADC12IV_ADC12IFG1: adc_values[1] = ADC12MEM1; break; case ADC12IV_ADC12IFG2: adc_values[2] = ADC12MEM2; break; case ADC12IV_ADC12IFG3: adc_values[3] = ADC12MEM3; break; case ADC12IV_ADC12IFG4: adc_values[4] = ADC12MEM4; break; case ADC12IV_ADC12IFG5: adc_values[5] = ADC12MEM5; break; case ADC12IV_ADC12IFG6: adc_values[6] = ADC12MEM6; break; case ADC12IV_ADC12IFG7: adc_values[7] = ADC12MEM7; break; } }