我编写了一个小程序,根据ADC10中断对MSP430G2553的内部温度传感器进行连续采样。但是,我的代码没有这样做。它仅触发一次中断,然后填充数组的第一个索引,然后停止。我想念什么?
#include <msp430g2553.h>
/**
* main.c
* Use ADC module to read the value of the MCU's internal temperature sensor
* and dump those values into an array.
*/
volatile unsigned counter = 0;
volatile unsigned temparr[20];
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + MSC; // Set ADC module
ADC10CTL1 = CONSEQ_0 + INCH_10 + ADC10DIV_7; // Set ADC module
ADC10DTC0 = ADC10CT; // Set ADC module
ADC10CTL0 |= ENC + ADC10SC; // Start ADC + sampling
__enable_interrupt();
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_IRS(void)
{
while (ADC10CTL1 & BUSY); // Give time to the ADC to settle
if (counter < 20) {
temparr[counter] = ADC10MEM;
counter++;
}
else {
counter = 0;
}
}
答案 0 :(得分:0)
#include <msp430g2553.h>
/**
* main.c
* Use ADC module to read the value of the MCU's internal temperature sensor
* and dump those values into an array.
*/
volatile unsigned counter = 0;
volatile unsigned temparr[20];
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + MSC; // Set ADC module
ADC10CTL1 = CONSEQ_2 + INCH_10 + ADC10DIV_7; // Set ADC module
ADC10DTC0 = ADC10CT; // Set ADC module
ADC10CTL0 |= ENC + ADC10SC;
__enable_interrupt();
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_IRS(void)
{
//while (ADC10CTL1 & BUSY); // Give time to the ADC to settle
if (counter < 20) {
temparr[counter] = ADC10MEM;
counter++;
}
else {
counter = 0;
ADC10CTL0 &= ~(ENC + ADC10SC);
}
}
看来这是调试器的问题。运行几次代码后,它才开始工作:S。我正在使用通过Spy-By-Wire直接连接到MSP430G2553芯片的MSP-FET闪存工具。我知道一些TI用户在最新固件更新(CCS8)之后报告了该设备的问题。