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.

Thermometer with LM35

Other Parts Discussed in Thread: LM35, MSP430G2553

Hello,

I'm having problems interfacing the LM35 sensor with MSP4302553.
My code:

------------------------------------------------------------------------------------------------------------------------------------------------

#include <msp430.h>
#include <intrinsics.h>

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;    // STOP WATCHDOG

    P1DIR = 0x1; // P1.0 OUTPUT
    P1OUT = 0x0; // P1.0 OFF

    ADC10CTL0 = SREF_1 | REFON | ADC10ON | ADC10SHT_3; // ADC SETTINGS
    ADC10CTL1 = INCH_1 | ADC10SSEL_3 | CONSEQ_0;
    ADC10AE0 = BIT1; // P1.1(A1) ANALOG INPUT

    DCOCTL = 0; // CLOCK SETTINGS
    BCSCTL1 = CALBC1_1MHZ;
    DCOCTL = CALDCO_1MHZ;

    TACTL = MC_1|ID_3|TASSEL_2|TACLR; // TIMER SETTINGS
    TACCR0 = 62499;
    TACCTL0 = CCIE;

    __enable_interrupt();

    for (;;)
    {
          __low_power_mode_0();
          ADC10CTL0 |= (ENC | ADC10SC);
    }

#pragma vector = TIMERA0_VECTOR
__interrupt void TA0_ISR(void){
    __low_power_mode_off_on_exit();
    }
}

--------------------------------------------------------------------------------------------------------------------------------------------
errors:
"../main.c", line 31: error #612: this kind of pragma may not be used here
"../main.c", line 32: error #68: expected a "}"
"../main.c", line 35: error #171: expected a declaration

  • Caio Fabio said:
    errors:
    "../main.c", line 31: error #612: this kind of pragma may not be used here
    "../main.c", line 32: error #68: expected a "}"
    "../main.c", line 35: error #171: expected a declaration

    Supposedly you forgot to ask a question and forgot to specify compiler (software development tool) you use.

    Well.. Most probably your problem is undefined TIMERA0_VECTOR. Depending on compiler used you shall properly define microcontroller type, msp430g2553 in the project properties or instead of including <msp430.h> try to include <msp430g2553.h>

  • Sorry for the lack of information. I'm using Code Composer Studio. I included <msp430g2553.h> in my code, but the same errors persist.

    Thanks for answering.

    New code:

    #include <msp430g2553.h>
    #include <intrinsics.h>

    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;    // STOP WATCHDOG

        P1DIR = 0x1; // P1.0 OUTPUT
        P1OUT = 0x0; // P1.0 OFF

        ADC10CTL0 = SREF_1 | REFON | ADC10ON | ADC10SHT_3; // ADC SETTINGS
        ADC10CTL1 = INCH_1 | ADC10SSEL_3 | CONSEQ_0;
        ADC10AE0 = BIT1; // P1.1(A1) ANALOG INPUT

        DCOCTL = 0; // CLOCK SETTINGS
        BCSCTL1 = CALBC1_1MHZ;
        DCOCTL = CALDCO_1MHZ;

        TACTL = MC_1|ID_3|TASSEL_2|TACLR; // TIMER SETTINGS
        TACCR0 = 62499;
        TACCTL0 = CCIE;

        __enable_interrupt();

        for (;;)
        {
              __low_power_mode_0();
              ADC10CTL0 |= (ENC | ADC10SC);
        }

    #pragma vector = TIMERA0_VECTOR
    __interrupt void TA0_ISR(void){
        __low_power_mode_off_on_exit();
        }
    }

  • I also defined the microcontroller type in the project properties. The question is "What is wrong with my code?".

  • Caio Fabio said:
    The question is "What is wrong with my code?".

    Your problem is that you put interrupt routine inside main() {} function.

  • Well, the second error line tells you what’s wrong: before the code in line 32, a closing bracket is expected. And indeed, you did not end (close) your main function before beginning the next function (the ISR).

    As a result, as Ilmars noted, your ISR tries to reside inside main, where neither the #pragma nor the ISR function declaration are valid.

**Attention** This is a public forum