MSP430G2553:连续 ADC10 采样(带中断)
MSP430G2553: continuous ADC10 sampling (with interrupt)
写了一个小程序,根据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;
}
}
#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。我正在使用通过线控间谍直接连接到 MSP430G2553 芯片的 MSP-FET 闪存工具。我知道一些 TI 用户在最新固件更新 (CCS8) 后报告了此装置的问题。
写了一个小程序,根据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;
}
}
#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。我正在使用通过线控间谍直接连接到 MSP430G2553 芯片的 MSP-FET 闪存工具。我知道一些 TI 用户在最新固件更新 (CCS8) 后报告了此装置的问题。