Hi there,
I have been using the following code in order to read the current sensor data. Which was working fine till last night. Suddenly today is stopped working when I was trying to read the ADC_value data in the expressions section, and it gave me the following error message,
ADC_value unknown Error: Could not read 0x0200: Execution state prevented access
I havent changed anything in the code or in the hardware, Could anyone please tell me if there is any obvious way to solve the problem?
#include <msp430g2553.h>
// the code posted below will perform a single read from GPIO P1.3 and then assigns the value to ADC10MEM to a variable calledd ADC_Value
// Global Variable
// Global variables
unsigned int ADC_value=0;
// Function prototypes
void ConfigureAdc(void);
void main(void)
{
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ;
BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO = 1MHz
P1SEL |= BIT3; // ADC input pin P1.3
ConfigureAdc(); // ADC set-up function call
__enable_interrupt(); // Enable interrupts.
while(1)
{
__delay_cycles(1000); // Wait for ADC Ref to settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // Low Power Mode 0 with interrupts enabled
ADC_value = ADC10MEM; // Assigns the value held in ADC10MEM to the integer called ADC_value // change the variable name // take another code // try another analog input
}
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(CPUOFF); // Return to active mode }
}
// Function containing ADC set-up
void ConfigureAdc(void)
{
ADC10CTL1 = INCH_3 + ADC10DIV_3 ; // Channel 3, ADC10CLK/3
ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; // Vcc & Vss as reference, Sample and hold for 64 Clock cycles, ADC on, ADC interrupt enable
ADC10AE0 |= BIT3; // ADC input enable P1.3
}
I am using msp430g2553 and I have been coding with it for a while but never faced such problem.
Bests,
Tahsina