I am using CCS (Code Composser Studio ) Version 6.0
MCU : MSP430G2230
Launch pad : MSP-TS430D8
I am going to execute example code for Turn ON LED if analog input is > 0.5 V on pin P1.5
Below is code :
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
/* Initialization Code */
P1REN = 0x1B; // Terminate unavailable Port1 pins (P1.0/1/3/4) properly
// Config as Input with pull-down enabled
BCSCTL3 |= LFXT1S_2; // Select VLO as low freq clock
/* End Initialization Code */
ADC10CTL0 = SREF_1 | ADC10SHT_2 | REFON | ADC10ON | ADC10IE;
__enable_interrupt(); // Enable interrupts.
TA0CCR0 = 30; // Delay to allow Ref to settle
TA0CCTL0 |= CCIE; // Compare-mode interrupt.
TA0CTL = TASSEL_2 | MC_1; // TACLK = SMCLK, Up mode.
LPM0; // Wait for delay.
TA0CCTL0 &= ~CCIE; // Disable timer Interrupt
__disable_interrupt();
ADC10CTL1 = INCH_5; // input A5
ADC10AE0 |= BIT5; // PA.1 ADC option select
P1DIR |= BIT2; // Set P1.2 to output direction
for (;;)
{
ADC10CTL0 |= ENC | ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exi
if (ADC10MEM < 0x156) // ADC10MEM = A5 > 0.5V?
P1OUT &= ~BIT2; // Clear P1.2 LED off
else
P1OUT |= BIT2; // Set P1.2 LED on
}
}
// ADC10 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC10_VECTOR))) ADC10_ISR (void)
#else
#error Compiler not supported!
#endif
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMERA0_VECTOR
__interrupt void ta0_isr(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMERA0_VECTOR))) ta0_isr (void)
#else
#error Compiler not supported!
#endif
{
TA0CTL = 0;
LPM0_EXIT; // Exit LPM0 on return
}
After debugging it shows error as below :
MSP430: Trouble Writing Memory Block at 0xf800 on Page 0 of Length 0x112: Could not write device memory
MSP430: GEL: File: C:\Users\admin\Desktop\MSP430G2230 Project Files\msp430g2230_adc10_02\Debug\msp430g2230_adc10_02.out: Load failed.
Please help.