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.

Compiler/MSP430L092: How to run asm program and find API functions

Part Number: MSP430L092
Other Parts Discussed in Thread: MSP-FET, MSP430FR2311, , TMS320F28332, MSP430F1121, MSP430WARE

Tool/software: TI C/C++ Compiler

When using MSP-FET430UIF and IAR5.30 to debug some applications, I met some problems as follows:
1, when making some projects of 430f1101, to c program it is all right, but for asm program it shows Error[e16] and says“Segment RESET() is too long for segment definition”. Though used the same linker commend file, why is it?
2, About debugging 430L092, of course, using the loader approach, also for c (ta_02.c)it is running normally, but for asm (ta_02.asm) it shows Error[40]  and says "Bad instruction" on ,global,.text ,.sect etc. What's wrong with it? Besides, I don’t know how to find the API-functions and how they are doing though I got the file of loader.h from TI E2E right now. Are there more  detailed examples about creating L092 autonomous applications for reference. Sorry, I'm a beginner.
Regards,
Jinping Ruan

  • Hello,

    Please check out the following threads that are related to this error. I suspect that you started with a C project and imported assembly code into it or vice versa.

    Also, I would recommend updating your tools and your device. I would start by using our newest debugger, the MSP-FET, and also trying out our Code Composer Studio (CCS) IDE. Is there a specific reason that you've chosen the L092? We offer much newer, better supported devices, including some exciting ones from our FRAM family, like the MSP430FR2311.

    Regards,

    James

    MSP Customer Applications

  • Part Number: MSP430L092

    Replay to Mr. James,

    Yes, there is some special reason, the ULV, I need to chose the L092.
    The main reason that asm programs could not be run in my IAR system may be they are developed from CCS.,though they are all be provided from your company. There are many differences between CCS and IAR for the assembler. Is it right?
    By the way, could you provide us some more examples of asm programs developed from IAR and for L092, and some programs showed Its API operation? If so, we will be easy  to master its developing.Thank you very much.
    Regards,
    Ruan

    Appendix:

    James Evans replied to Compiler/MSP430L092: How to run asm program and find API functions.

    Hello,

    Please check out the following threads that are related to this error. I suspect that you started with a C project and imported assembly code into it or vice versa.

    Also, I would recommend updating your tools and your device. I would start by using our newest debugger, the MSP-FET, and also trying out our Code Composer Studio (CCS) IDE. Is there a specific reason that you've chosen the L092? We offer much newer, better supported devices, including some exciting ones from our FRAM family, like the MSP430FR2311.

    Regards,

    James

    MSP Customer Applications

  • Jinping Ruan said:
    Yes, there is some special reason, the ULV, I need to chose the L092.

    Thanks! This makes sense.

    Jinping Ruan said:
    The main reason that asm programs could not be run in my IAR system may be they are developed from CCS.,though they are all be provided from your company. There are many differences between CCS and IAR for the assembler. Is it right?

    Are you required to use IAR? We offer several assembly code examples for the L09 for CCS, but not IAR. You can download those code examples from the Tools & Software tab (under Software section) on the L092 product folder. You're correct that there are differences between the CCS and IAR compilers and the assembly code would need to be ported.

    Since CCS is free now and the examples support CCS, I would highly recommend going this route for your development.

    Regards,

    James

    MSP Customer Applications

  • Yes, I have developed many programs used CCS for like TMS320F28332 etc. Yet for L092, I have to work with your MSP430L092 target board kit that will be connected to the MSP FET430UIF used ISR. It seems that there are many differences between the JTAG pin layouts for emulators of 430UIF and XDS100 (for 28332). I have no idea if 430UIF can use CCS and how it can be done.
    Regards,
    Ruan
  • Hello Ruan,

    Yes, the MSP-TS430L092 target board and the MSP-FET are supported by CCS. The legacy MSP-FET430UIF is not recommended for new designs (NRND). The 14-pin connector of the MSP-FET plugs into the L092 Active Cable board that's connected to the MSP-TS430L092 target board. You can find more details about how to use the MSP-TS430L092 target board by searching for the part number in the MSP430 Hardware Tools User's Guide. More specifically, refer to Figures B-6 and B-8.

    Regards,

    James

    MSP Customer Applications

  • I see that CCS should support the MSP-FET, but for my CCS V6.1.3, there is no .gel for TMS430F1121 and L092, so it could not be configured. Besides, for driving my MSP-FET430UIF, it’s hardware need to be upgraded, as my IAR using is V 5.3. By the way, could you let me know which one is the active emulator for it?
    By using IAR, still some of the programs can be debugged and some can not.
    Regards,
    Ruan
  • Jinping Ruan said:
    I see that CCS should support the MSP-FET, but for my CCS V6.1.3, there is no .gel for TMS430F1121 and L092, so it could not be configured.

    I'm assuming that you meant "MSP430F1121" instead of "TMS430F1121". I'm not familiar with .gel files. After reading about them online, they seem to be used for processors, not microcontrollers. For MSP430, the target configuration is defined in the .ccxml file. Thus, you don't need to worry about the .gel file here.

    Jinping Ruan said:
    Besides, for driving my MSP-FET430UIF, it’s hardware need to be upgraded, as my IAR using is V 5.3. By the way, could you let me know which one is the active emulator for it?
    By using IAR, still some of the programs can be debugged and some can not.

    Since you already have the MSP-TS430L092 target board and the MSP-FET430UIF, you can use IAR or CCS to easily get started. Have you tried connecting everything, selecting an example assembly project, programming the device, and debugging it yet? Again, you can find more details about how to use the MSP-TS430L092 target board by searching for the part number in the MSP430 Hardware Tools User's Guide. More specifically, refer to Figures B-6 and B-8.

    While slightly dated, take a look at the following L092 Introduction video with presentation. It should help fill in the gaps. Otherwise, I'm not sure how much more help I can be here.

    Regards,

    James

    MSP Customer Applications

  • Hi James,


    After a period of learning, I am familiar with the performance and operation of L092 and IAR Tool gradually. Yet, there are still the following questions to be asked for help.
    1, According to the chapter 2.2.3 of literature number: SLAU321, it pointes that the HF-OSC of L092 may be internal trimmed and provides a stable frequency. But I have no idea how to do the internal trimmed. Not like for F1101, I could not find any information or example programs for doing this. Could you give me some help to solve it?
    2, Can you recommend the model of the external clock (the crystal oscillator) and how can we meet the requirements of such a low power supply of L 092?
    3, Debugging with IAR for F1101, I use the program given in appendix. When WDTCTL=WDT-MDLY-8 is used, the work is normal, but with WDTCTL=WDT-ADLY-250, there is no way to enter the interruption ISR. Please let me know what is the matter.

    Regards,
    Ruan


    appendix:

    #include <msp430x11x1.h>
    void main(void)
    {
    WDTCTL = WDT_ADLY_250; //WDT 250ms, ACLK, interval timer
    IE1 |= WDTIE; // Enable WDT interrupt
    P1DIR |= 0x01; // Set P1.0 to output direction
    
    _BIS_SR(LPM0_bits + GIE); // Enter LPM3 w/interrupt
    }
    
    // Watchdog Timer interrupt service routine
    #pragma vector=WDT_VECTOR
    __interrupt void watchdog_timer(void)
    {
    P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
    }
  • Jinping Ruan said:
    1, According to the chapter 2.2.3 of literature number: SLAU321, it pointes that the HF-OSC of L092 may be internal trimmed and provides a stable frequency. But I have no idea how to do the internal trimmed. Not like for F1101, I could not find any information or example programs for doing this. Could you give me some help to solve it?

    The User's Guide mentions that CCSCTL2 can be used for frequency trimming the HF-OSC. The default value is 0101000b for ~1MHz operation. Using the lower (0000000b) and upper limits (1111111b) in CCSCTL2, you can achieve ~0.565MHz to ~2.3MHz frequencies, respectively. Just make sure you modify this register when CCS is unlocked. For example, I would do it between the CCSCTL4 and CCSCTL5 register configurations in the 'msp430x09x_ccs_hfosc.c' code example below.

    Edit: Changed bold values from "0.7MHz to 1.3MHz frequencies" to "~0.565MHz to ~2.3MHz frequencies".

    msp430x09x_ccs_hfosc.c

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    /* Description: This program demonstrates how to configure ACLK, MCLK, and SMCLK */
    /* to use the HF clock source.                                                   */
    /****************************Timer_A0*********************************************/
    /*  Requirements:Oscilloscope                                                    */
    /*                                                                               */
    /*                                                                               */
    /*                               +----L092---+                                   */
    /*                               |*1      14 |                                   */
    /*                               | 2      13 |                                   */
    /*                               | 3      12 |  -> P1.4 MCLK ~1MHz               */
    /*                               | 4      11 |                                   */
    /*                               | 5      10 |                                   */
    /*     P1.0 ACLK ~1MHz   <-      | 6       9 |                                   */
    /*     P1.1 SMCLK ~1MHz  <-      | 7       8 |                                   */
    /*                               +-----------+                                   */
    /*                                                                               */
    /*  D.Dang/D.Archbold/D.Szmulewicz                                               */
    /*  Texas Instruments Inc.                                                       */
    /*  Built with IAR Version 5.10.4                                                */
    /*********************************************************************************/
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW + WDTHOLD;
    
       // Setup Port 1 to output ACLK, SMCLK, and MCLK
       // P1.0 = ACLK -> P1DIR.0 = 1; P1SEL0.0 = 1; P1SEL1.0 = 1;
       // P1.1 = SMCLK-> P1DIR.1 = 1; P1SEL0.1 = 1; P1SEL1.1 = 1;
       // P1.4 = MCLK -> P1DIR.4 = 1; P1SEL0.4 = 1; P1SEL1.4 = 1;
        
        P1DIR  |= BIT0 + BIT1 + BIT4;               
        P1SEL0 |= BIT0 + BIT1 + BIT4;                
        P1SEL1 |= BIT0 + BIT1 + BIT4;               
    	
    	/************************/
    	/* Setup CCS            */
    	/* ACLK = HFCLK/DCO     */
            /* MCLK = HFCLK/DCO     */
            /* SMCLK = HFCLK/DCO    */
    	/************************/
        
        CCSCTL0 = CCSKEY;                      // Unlock CCS  
        
        while (SFRIFG1 & OFIFG)                // Oscillator Flag(s)?
      {
        CCSCTL7 = 0;                           // Clear HF & LF OSC fault flags
        SFRIFG1 = 0;                           // Clear OFIFG  
      }
      
        CCSCTL4 = SELA_0 + SELM_0 + SELS_0;    // Select HFCLK/DCO as the source for ACLK, MCLK, and SMCLK  
        CCSCTL5 = DIVA_0 + DIVM_0 + DIVS_0;    // Set the Dividers for ACLK, MCLK, and SMCLK to 1
        CCSCTL0_H |= 0xFF;                     // Lock CCS
    	
            /* Lock by writing to upper byte */	
    	
        while(1);
    
    }

    Jinping Ruan said:
    2, Can you recommend the model of the external clock (the crystal oscillator) and how can we meet the requirements of such a low power supply of L 092?

    My best recommendation would be to check the target socket board BOM to see what external clock was used. Also, make sure the crystal meets any requirements specified in the datasheet. In Section 2.2.4 External Clock Source in the User's Guide, it mentions that CLKIN may be used with external clock signals on the CLKIN-pin by selecting CLKIN as source. When used with an external signal, the external frequency must meet the data sheet parameters.

    Jinping Ruan said:
    3, Debugging with IAR for F1101, I use the program given in appendix. When WDTCTL=WDT-MDLY-8 is used, the work is normal, but with WDTCTL=WDT-ADLY-250, there is no way to enter the interruption ISR. Please let me know what is the matter.

    See if the ISR gets executed when you're NOT debugging. Sometimes the active debug session can mess with the clocks and timings.

    Regards,

    James

    MSP Customer Applications

  • Thank you for your help. I have finished a design of my program for L092. I bought the BOM of MSP-TS430L092 Rev.1.1, but there is no external clock on it at all. I have looked for it for long, but feel no one is suit it, especially for the low supply voltage, so ask if you could give some recommended models.
    Regards,
    Ruan
  • Hello,

    After a quick web search, I found the Diodes LX501 oscillator series with an input voltage range from 0.9V to 1.5V and frequency range from 1.25MHz to 50MHz. However,  I couldn't find them in stock anywhere. I would recommend finding something similar if you need to operate at 0.9V.

    Diodes LX501 Series datasheet

    I'm not sure what frequency you want, but I did find some Epson SG-3040LC oscillators with a 0.9V supply voltage and 32.768kHz frequency. I found some other oscillators that operate at 0.9V supply voltage but they had 24MHz frequency which is way too high for the L092.

    Digi-key search results

    SG-3040LC 32.7680KB3:PURE SN

  • Hi James,
    Thank you. It seems that many problems have been solved. But when running the msp430x09x_apool_adc_06, Sampled Temperature program you given, there are more problems. The related.C and.Asm programs are duplicated as follows.
    1, to .c file
    The first time , after the project is generated and running Linker, it shows the error of [e46], as a message under the attachment program; using the same method, another project is created, but it can be successfully passed. The debugging results: using the original program, both Result and DegC are 0; changed the original program by deleting +OSWP in APCTL, get Result = 166 and DegC = 0. All is not correct.
    2. to .asm file
    Since I used the debug tool of IAR, I have modified your program (other programs can run correctly after modification, but this program have .BSS items, I do not know if its modification is correct?). Debug results: Result=16533, DegC=16562. In particular, to the last few instructions I do not know how can to get DegC. After running them, R12 is 0xx0008, but why the DegC shown in “watch” is 16562.
    Though repeatedly debugging, problems still can not be solved. Is it a software or hardware problem? Please guide.
    By the way, it is really difficult to find crystal oscillator to meet Freq. 960KHz or 1.2MHz at 0.9V.
    Regards,
    Ruan

    /* Description: ADC Temperature Sample, msp430x09x_apool_adc_06.c
    #include "msp430l092.h"
    int Result;
    volatile unsigned long int DegC;
    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    // Begin Configuration of the A-POOL registers
    APCTL = 0; // Clear APCTL register
    APIE |= EOCIE; // Enable Interrupt for End of Conversion
    APTRIM = REFTSEL;
    APVDIV = TMPSEN; // Enable Temperature Sensor
    APCNF = CMPON+DBON+CONVON+APREFON+CLKSEL_MCLK;
    // Configure A-POOL elements, Select MCLK as A-POOL Clock Source
    APCTL = OSEL+ODEN+OSWP+APPSEL_5+APNSEL_4; // Set Channels and Start Conversion
    APINT = 0x00; // Clear ADC-DAC-REG
    APCTL |= CBSTP+SBSTP+RUNSTOP;
    __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts enabled
    Result = APINT;
    DegC = (int)(Result-179)*(1/0.464)+30; // Refer to datasheet for accuracy and offset specs
    __no_operation(); // SET BREAKPOINT HERE
    }
    //A_POOL Interrupt Service Routine
    #pragma vector=APOOL_VECTOR
    __interrupt void A_POOL(void)
    {
    APIFG = 0; // Clear Interrupt Flag
    __bic_SR_register_on_exit(LPM0_bits); // Exit Active to calculate Temperature
    }
    Massage:
    Linking
    Warning[w60]: The entry point label "__program_start" was not found in any input file. The image will not have an entry point
    Error[e46]: Undefined external "__program_start" referred in ?ABS_ENTRY_MOD ( )
    Error while running Linker


    ; Description: ADC Temperature Sample msp430x09x_apool_06.asm
    ; .cdecls C,LIST,"msp430x09x.h"
    ;-------------------------------------------------------------------------------
    ; .data ; RAM variables
    ; COMMON DATA16_C
    Result DS8 2
    DegC DS8 4
    DegF DS8 4
    ;------------------------------------------------------------------------------
    ; .bss Result,2
    ; .bss DegC,4
    ; .bss DegF,4
    ;-------------------------------------------------------------------------------
    ; .global main
    ; .text ; Assemble to memory
    ;-------------------------------------------------------------------------------
    ;main
    #include "msp430l092.h"
    ORG 01C80h

    RESET mov.w #0x2400,SP ; Initialize stack pointer
    mov.w #WDTPW + WDTHOLD,&WDTCTL ; Stop WDT

    ; Begin Configuration of the A-POOL registers

    mov.w #0,&APCTL ; Clear APCTL register
    bis.w #EOCIE,&APIE ; Enable Interrupt for End of Conversion
    mov.w #REFTSEL,&APTRIM
    mov.w #TMPSEN,&APVDIV ; Enable Temperature Sensor
    mov.w #CMPON+DBON+CONVON+APREFON+CLKSEL_MCLK,&APCNF ; Configure A-POOL elements, Select MCLK as A-POOL Clock Source

    mov.w #OSEL+ODEN+APPSEL_5+APNSEL_4,&APCTL ; Set Channels and Start Conversion
    mov.w #0,&APINT ; Clear ADC-DAC-REG

    bis.w #CBSTP+SBSTP+RUNSTOP,&APCTL;
    bis.w #LPM0+GIE,SR ; Enter LPM0 w/ interrupts enabled

    mov.w &APINT,&Result
    mov.w &Result, R12
    mov.w #169,R12
    sub.w #165,R12 ; Subtract 165
    rla R12 ; Multiply by 2
    mov.w R12,&DegC ; Simple example with roundings. For more accurate result please refer to C code example

    nop ; SET BREAKPOINT HERE
    ;-------------------------------------------------------------------------------
    A_POOL_ISR ;A_POOL Interrupt Service Routine
    ;-------------------------------------------------------------------------------
    mov.w #0,&APIFG ; Clear Interrupt Flag
    bic.w #LPM0,0(SP) ; Modify SP so that it enters active mode after reti
    reti ; Return from ISR
    ;------------------------------------------------------------------------------
    ; Interrupt Vectors
    ;------------------------------------------------------------------------------
    COMMON INTVEC ; Interrupt vectors
    ORG RESET_VECTOR
    DW RESET
    ORG APOOL_VECTOR
    DW A_POOL_ISR ;A_POOL VectorWDT_ISR
    END

    ; .sect ".int09" ; A_POOL_vector
    ; .short A_POOL_ISR ;A_POOL Vector
    ; .end
  • Hello,

    Using the latest "msp430x09x_apool_adc_06" code example from MSP430Ware v3.80.04.05 in CCS v8, I built the project with no errors. I would recommend using the latest version of IAR and downloading the latest version of MSP430Ware to ensure you have the latest version of this code example.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    /*   Description:  ADC Temperature Sample                                        */
    /****************************A_POOL ADC Conversion *******************************/
    /*                                                                               */
    /*                                                                               */
    /*              +----L092---+                                                    */
    /*              |*1      14 |                                                    */
    /*              | 2      13 |                                                    */
    /*              | 3      12 |                                                    */
    /*              | 4      11 |                                                    */
    /*              | 5      10 |                                                    */
    /*              | 6       9 |                                                    */
    /*              | 7       8 |                                                    */
    /*              +-----------+                                                    */
    /*                                                                               */
    /*  D.Dang/ D.Archbold/ D.Szmulewicz /F. Chen                                            */
    /*  Texas Instruments Inc.                                                       */
    /*  Built with IAR Version 5.51.1 and CCS Verison 5.3.00090                                               */
    /*********************************************************************************/
    
    #include <msp430.h>
    
    int Result;
    volatile  short int DegC;
    
    
    int main(void)
    {
       WDTCTL = WDTPW + WDTHOLD;                                       // Stop WDT
    
      // Begin Configuration of the A-POOL registers
    
        APCTL = 0;                                                     // Clear APCTL register
        APIE |= EOCIE;                                                 // Enable Interrupt for End of Conversion
        APTRIM = REFTSEL;
        APVDIV = TMPSEN;                                               // Enable Temperature Sensor
        APCNF = CMPON+DBON+CONVON+APREFON+CLKSEL_MCLK;                 // Configure A-POOL elements, Select MCLK as A-POOL Clock Source
    
    
        while(1)
    	{
    
        APCTL = OSEL+ODEN+OSWP+APPSEL_4+APNSEL_5;                                // Set Channels and Start Conversion--+ODEN+
        APINT = 0x00;                                                  // Clear ADC-DAC-REG
        APIFG = 0;
        APCTL |= CBSTP+SBSTP+RUNSTOP;
        __bis_SR_register(LPM0_bits + GIE);                           // Enter LPM0 w/ interrupts enabled
    
        Result = APINT;
        DegC =(((Result-179)*125)/58) + 30;                                   // Refer to datasheet for accuracy and offset specs
    
        __no_operation();                                             // SET BREAKPOINT HERE
    
      }
    
    }
    
    
    //A_POOL Interrupt Service Routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=APOOL_VECTOR
    __interrupt void A_POOL(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(APOOL_VECTOR))) A_POOL (void)
    #else
    #error Compiler not supported!
    #endif
    {
        APIFG = 0;                                                     // Clear Interrupt Flag
    __bic_SR_register_on_exit(LPM0_bits);                              // Exit Active to calculate Temperature
    
    
    }

    Also, I would not recommend using the L092's internal temperature sensor for your application because it's relatively inaccurate. Instead, I would recommend using an external temp sensor. Here are some related E2E threads discussing this in more detail.

    MSP430L092: Temperature Sensor Issues

    MSP430L092: TEMPERATURE SENSOR MEASURING ERROR

    MSP430L092: How can I combine temperature sensor code and reading analog value code?

    Regards,

    James

  • Hi James,
    Thanks for your help, most of the problems have been basically solved. There’s one thing that’s always confusing. The frequency trimming you’re talking about can be from 0.7MHz(0000000b) to 1.3MHz (1111111b), which is consistent with fHFOSC of the first item in the table of SLAS673 p27, the datasheet for MSP430L092, but I don’t know what the fHFOSC of the second item means. How did it get from 0.92 to1.08MHz? What’s more, why can the following Figure 12 be from nearly from 2.4MHz (0) to 0.6MHz (128)?
    Regards,
    Ruan
  • Hi Ruan,

    I think I've made a mistake, and I fully understand why you're confused. I'm sorry about that. For some reason, I did not see or properly understand Figure 12 in the datasheet. As illustrated in Figure 12, the trim value for the internal HFOSC defined by the CCSCTL2 register ranges from approximately 565kHz (1111111b) up to 2.3MHz (0000000b). I confirmed this using the target socket board.

    Also, I confirmed that the default CCSCTL2 (0101000b) configures the internal HFOSC to operate at approximately ~1MHz. Now, looking at the table at the top of page 27 in the datasheet, I see what you're referring to here. Here's my interpretation.

    The frequency ranges for HFOSC seem to indicate the variation of the default CCSCTL2 trim value. The first row is for room temperature, and the second row is for 30C. Now, looking at the normalized plot of HFOSC frequency versus Temperature in Figure 13 in the datasheet, the difference between the first and second rows can be explained. Figure 13 tells us that as the temperature decreases, the frequency increases compared to the frequency at 30C. This matches what's shown in the first row. As temperature increases, the frequency decreases more quickly than the frequency at 30C. Now, the plots in Figure 13 may not match the values provided in the first and second rows, but I would assume that the plots are based on typical values. The min and max values in the first and second rows would be worst case.

    I'm sorry for adding to the confusion, but I really hope this helps clear that up. It was definitely a learning experience for me, so thank you for your patience.

    Regards,

    James

**Attention** This is a public forum