This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
#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); } }
I wrote a small program to continuously sample the internal temperature sensor of the MSP430G2553 based on the ADC10 interrupt. My code, however, does not do that. It triggers the interrupt (only) once, it populates the first index of the array, and then it stops. What am I missing? Thanks.
Hi Lukas. Thank you for the suggestion. I have looked at all the ADC10 examples - under the ti resource explorer. Though most ADC examples seem to be geared towards the G2x33 family, I assumed they would work the same for the G2553. Part of my problem (I think) is that In my mind, the use of interrupts eliminates the need for a loop (therefore the need to trap the CPU indefinitely). Because of the ADC10 control registers setup (continuous sampling) and the enabling of the ADC10 interrupt, the ISR would get triggered after the ADC10MEM would be populated with the conversion continuously until the ENC bit would be set to 0. Am I understanding the workflow correctly?
I know this is probably going to sound insane: I have ran the same program a few times. All of the sudden my code started to work. Can it be a debugger problem? I know that MSP-FET has been giving people a harder time (after the last update). Well, now it works! No loops, nothing! Thank you much for running this on your G2553 Launchpad.
**Attention** This is a public forum