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.

CCS/MSP430G2553: MSP430_LCD16x2_library_question

Part Number: TMS570LS3137
Other Parts Discussed in Thread: MSP430G2553, MSP430FR6989, MSP430FR5994, ENERGIA, CCSTUDIO

Tool/software: Code Composer Studio

Hi guys,

I am try to find lcd1602 library ,but i can't find great library for use.

So i want to transplant Arduino lcd library to msp430G2553.

But some question i meet.

My code composer can compiler for arduino library(which is i change the code)

but i write the command one for "LiquidCrystal lcd(1,2,3,4,5,6);" ,then some mistake rebuild.

like picutre

and my library is upload. 

LiquidCrystal.cppLiquidCrystal.h

this is i am try to transplant it is not complete modify the code . plze help me

  • Hello User,

    my first impression,
    you are mixing C and C++ code and do not keep a convention needed to link both worlds.
    Check this thread: e2e.ti.com/.../728701
  • so,you mean the ccs can't use c++ to comiple the code?

  • No, I say that C and C++ can be mixed together under CCS.
  • So,how can i call the library code if i can't mix the code?
  • so , how should i declare the c++ library if i want to use code?

  • Hi,

    For mixing C and C++ code, I strongly recommend you to take a look at the article below:
    processors.wiki.ti.com/.../C++_Support_in_TI_Compilers

    Section 3.8 talks about the name mangler, which is an important detail for this process.

    Hope this helps,
    Rafael
  • Please check the thread referred in my first reply to you.
  • i watch the user guide , but i don't know the answer . the use guide is not friendly and detail.
    Could u supply the example that code can run for me?
  • Why do not you try to start an empty C++ project?
    Please look at bigtime.cpp which is available under MSP430FR5994, MSP430FR6989, MSP432P401R and many others.

  • Could supply the link for me . I could't findd the bigtime.cpp

  • /*
     * Copyright (c) 2015-2016, 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.
     */
    
    /*
     *  ======== bigtime.cpp ========
     */
    
    /* XDC module Headers */
    #include <xdc/std.h>
    #include <xdc/runtime/Diags.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS module Headers */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Clock.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define TASKSTACKSIZE   512
    
    class Clock {
        private:
             // data
             int id;
             double ticks;
             int microsecond;
             int millisecond;
             int second;
             int minute;
             int hour;
             int day;
             int month;
             int year;
             int century;
             int millenium;
             Diags_Mask clockLog;
    
        public:
            // methods
            Clock(int newId);  // Constructor
            ~Clock();          // Destructor
            void tick();
            long getTicks();
            int getId();
            int getMicrosecond();
            int getMillisecond();
            int getSecond();
            int getMinute();
            int getHour();
            int getDay();
            int getMonth();
            int getYear();
            int getCentury();
            int getMillenium();
            void setMicrosecond();
            void setMillisecond();
            void setMillisecond(int nMilliseconds);
            void setSecond();
            void setMinute();
            void setHour();
            void setDay();
            void setMonth();
            void setYear();
            void setCentury();
            void setMillenium();
    };
    
    const char *months[12] = { "January", "February", "March",
                               "April",   "May",      "June",
                               "July",    "August",   "September",
                               "October", "November", "December" };
    
    /*
     * Extern "C" block to prevent name mangling
     * of functions called within the Configuration
     * Tool
     */
    extern "C" {
    
    /* Wrapper function to terminate the example */
    void clockTerminate(UArg arg);
    
    /* Wrapper functions to call Clock::tick() */
    void clockTask(UArg arg);
    void clockPrd(UArg arg);
    void clockIdle(void);
    
    } // end extern "C"
    
    /* Global clock objects */
    Clock cl0(0);  /* idle loop clock */
    Clock cl1(1);  /* periodic clock, period = 1 ms */
    Clock cl2(2);  /* periodic clock, period = 1 sec */
    Clock cl3(3);  /* task clock */
    Clock cl4(4);  /* task clock */
    
    Task_Struct task0Struct, task1Struct;
    Char task0Stack[TASKSTACKSIZE], task1Stack[TASKSTACKSIZE];
    Semaphore_Struct sem0Struct, sem1Struct;
    Semaphore_Handle sem0Handle, sem1Handle;
    Clock_Struct clk0Struct, clk1Struct;
    
    /*
     *  ======== main ========
     */
    Int main()
    {
    
        /* Construct BIOS objects */
        Task_Params taskParams;
        Semaphore_Params semParams;
        Clock_Params clkParams;
    
        /* Construct clock Task thread */
        Task_Params_init(&taskParams);
        taskParams.arg0 = (UArg)&cl3;
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        Task_construct(&task0Struct, (Task_FuncPtr)clockTask, &taskParams, NULL);
    
        taskParams.stack = &task1Stack;
        taskParams.arg0 = (UArg)&cl4;
        Task_construct(&task1Struct, (Task_FuncPtr)clockTask, &taskParams, NULL);
    
        /* Construct Semaphores for clock thread to pend on, initial count 1 */
        Semaphore_Params_init(&semParams);
        Semaphore_construct(&sem0Struct, 1, &semParams);
        /* Re-use default params */
        Semaphore_construct(&sem1Struct, 1, &semParams);
    
        /* Obtain instance handles */
        sem0Handle = Semaphore_Handle(&sem0Struct);
        sem1Handle = Semaphore_Handle(&sem1Struct);
    
        Clock_Params_init(&clkParams);
        clkParams.period = 100;
        clkParams.startFlag = true;
        clkParams.arg = (UArg)&cl1;
        Clock_construct(&clk0Struct, (Clock_FuncPtr)clockPrd,
                        1, &clkParams);
    
        clkParams.period = 1000;
        clkParams.startFlag = true;
        clkParams.arg = (UArg)&cl2;
        Clock_construct(&clk1Struct, (Clock_FuncPtr)clockPrd,
                        1, &clkParams);
    
        System_printf("bigTime started.\n");
    
        BIOS_start();    /* does not return */
        return(0);
    }
    
    /*
     *  ======== clockTerminate ========
     *  This function simply terminates the example
     */
    void clockTerminate(UArg arg)
    {
        System_printf("bigTime ended.\n");
        BIOS_exit(0);
    }
    
    /*
     *  ======== clockTask ========
     *  Wrapper function for Task objects calling
     *  Clock::tick()
     */
    void clockTask(UArg arg)
    {
        Clock *clock = (Clock *)arg;
        int count = 0;
    
        if (clock->getId() == 3) {
            for(;;) {             // task id = 3
                Semaphore_pend(sem0Handle, BIOS_WAIT_FOREVER);
                clock->tick();
                if(count == 50) {
                    Task_sleep(25);
                    count = 0;
                }
                count++;
                Semaphore_post(sem1Handle);
            }
        }
        else {
            for(;;) {             // task id = 4
                Semaphore_pend(sem1Handle, BIOS_WAIT_FOREVER);
                if(count == 50) {
                    Task_sleep(25);
                    count = 0;
                }
                clock->tick();
                count++;
                Semaphore_post(sem0Handle);
            }
        }
    }
    
    /*
     * ======== clockPrd ========
     * Wrapper function for PRD objects calling
     * Clock::tick()
     */
    void clockPrd(UArg arg)
    {
        Clock *clock = (Clock *)arg;
    
        clock->tick();
        return;
    }
    
    /*
     * ======== clockIdle ========
     * Wrapper function for IDL objects calling
     * Clock::tick()
     * It also calls System_flush() to periodically
     * print the contents in the SysMin buffer
     */
    void clockIdle(void)
    {
        cl0.tick();
        System_flush();
        return;
    }
    
    /*
     * Clock methods
     */
    Clock::Clock(int newId)
    {
        id = newId;
        ticks = 0;
        microsecond = 0;
        millisecond = 0;
        second = 0;
        minute = 0;
        hour = 0;
        day = 19;
        month = 8;
        year = 10;
        century = 20;
        millenium = 0;
    }
    
    Clock::~Clock()
    {
    }
    
    void Clock::tick()
    {
        ticks++;
    
        if (getId() == 1) {
            System_printf("id %d : %d:%d:%d.%d\n", getId(), hour, minute, second, millisecond / 100);
            System_printf("id %d : %s %d, %d%d\n", getId(), (IArg)months[month-1], day, century, year);
            /*
             * id 1 expires every 100 ticks (and each tick is 1 millisecond)
             */
            setMillisecond(100);
        }
        if (getId() == 2) {
            System_printf("id %d : %d:%d:%d\n", getId(), hour, minute, second);
            System_printf("id %d : %s %d, %d%d\n", getId(), (IArg)months[month-1], day, century, year);
            /*
             * Change selected function to alter clock rate
             */
    //      setMicrosecond();
    //      setMillisecond();
            setSecond();
    //      setMinute();
    //      setDay();
            if (ticks == 2) {
                clockTerminate(0);
            }
        }
    
        return;
    }
    
    void Clock::setMicrosecond()
    {
        if (microsecond >= 999) {
            setMillisecond();
            microsecond = 0;
        }
        else {
            microsecond++;
        }
    
        return;
    }
    
    void Clock::setMillisecond()
    {
        if (millisecond >= 999) {
            setSecond();
            millisecond = 0;
        }
        else {
            millisecond++;
        }
    
        return;
    }
    
    void Clock::setMillisecond(int nMilliseconds)
    {
        int secs;
    
        millisecond += nMilliseconds;
        secs = millisecond / 1000;
        millisecond %= 1000;
    
        while (secs--) {
            setSecond();
        }
    
        return;
    }
    
    void Clock::setSecond()
    {
        if (second == 59) {
            setMinute();
            second = 0;
        }
        else {
            second++;
        }
    
        return;
    }
    
    void Clock::setMinute()
    {
        if (minute == 59) {
            setHour();
            minute = 0;
        }
        else {
            minute++;
        }
    
        return;
    }
    
    void Clock::setHour()
    {
        if (hour == 23) {
            setDay();
            hour = 0;
        }
        else {
            hour++;
        }
    
        return;
    }
    
    void Clock::setDay()
    {
        bool thirtydays = false;
        bool feb = false;
        bool leap = false;
    
        if (month == 4 || month == 6 || month == 9 || month == 11) {
            // April, June, September, November.
            thirtydays = true;
        }
    
        if (month == 2) {  // Test for February
            feb = true;
        }
    
        /*
         * A year is a leap year if it is divisible by 4, but not by 100.
         *
         * If a year is divisible by 4 and by 100, it is a leap year only
         * if it is also divisible by 400.
         */
        if ((year%4 == 0 && year%100 != 0) ||
                (year%4 == 0 && year%100 == 0 && year%400 == 0)) {
            leap = true;
        }
    
        if ((day == 28) && (feb) && (!leap)) {
            setMonth();
            day = 1;
        }
        else if ((day == 29) && (feb) && (leap)) {
            setMonth();
            day = 1;
        }
        else if ((day == 30) && (thirtydays == true)) {
            setMonth();
            day = 1;
        }
        else if ((day == 31) && (thirtydays == false)) {
            setMonth();
            day = 1;
        }
        else {
            day++;
        }
    
        return;
    }
    
    void Clock::setMonth()
    {
        if (month >= 12) {
            setYear();
            month = 1;
        }
        else {
            month++;
        }
    
        return;
    }
    
    void Clock::setYear()
    {
        year++;
        if ((year%100) == 0) {
            setCentury();
        }
    
        return;
    }
    
    void Clock::setCentury()
    {
        century++;
        if ((century%10) == 0) {
            setMillenium();
        }
    
        return;
    }
    
    void Clock::setMillenium()
    {
        millenium++;
    
        return;
    }
    
    long Clock::getTicks()
    {
        return ticks;
    }
    
    int Clock::getId()
    {
        return id;
    }
    
    int Clock::getMicrosecond()
    {
        return microsecond;
    }
    
    int Clock::getMillisecond()
    {
        return millisecond;
    }
    
    int Clock::getSecond()
    {
        return second;
    }
    
    int Clock::getMinute()
    {
        return minute;
    }
    
    int Clock::getHour()
    {
        return hour;
    }
    
    int Clock::getDay()
    {
        return day;
    }
    
    int Clock::getMonth()
    {
        return month;
    }
    
    int Clock::getYear()
    {
        return year;
    }
    
    int Clock::getCentury()
    {
        return century;
    }
    
    int Clock::getMillenium()
    {
        return millenium;
    }
    

  • this cpp is not helpful for me , my question is i need to declare c++ constructor & Deconstructor

    how to write or declare , not supply no useful information.

    is is difficult to find c++ on css IDE , I think that css is a terrible IDE software and not friendly.

    this is simply to declare c++ constructor on Arduino IDE , but css is terrible and difficult.

    if I want to use ccs , i need to read vast complicated information, could u tell me how to do direct and simply?

    I am very Anxious write code..............
  • <<< this cpp is not helpful for me , my question is i need to declare c++ constructor & Deconstructor

    It is helpful for you.

    Issue is like this:

    - Arduino gives you the C++ interface

    - creating main.c you have started with the C interface

    - because C++ function overloading, C++ has to use a different linking interface than the C standard

    - bigtime example show how to construct C++ main.cpp a how to mix it a the C calls.

    I have created an empty C project, using CCS Project Explorer I have renamed main.c to main.cpp.

    #include <msp430.h> 
    
    
    /**
     * main.cpp
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    	return 0;
    }
    

    That new C++ project compiled without errors and with some warnings:

    **** Build of configuration Debug for project user5072621_MSP430G2553 ****
    
    "C:\\ti\\ccs810\\ccsv8\\utils\\bin\\gmake" -k -j 2 all -O 
     
    Building file: "../main.cpp"
    Invoking: MSP430 Compiler
    "C:/ti/ccs810/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --use_hw_mpy=none --include_path="C:/ti/ccs810/ccsv8/ccs_base/msp430/include" --include_path="C:/TI_Trash/CCS810/user5072621_MSP430G2553" --include_path="C:/ti/ccs810/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --define=__MSP430G2533__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.cpp"
    Finished building: "../main.cpp"
     
    Building target: "user5072621_MSP430G2553.out"
    Invoking: MSP430 Linker
    "C:/ti/ccs810/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --use_hw_mpy=none --advice:power=all --define=__MSP430G2533__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number -z -m"user5072621_MSP430G2553.map" --heap_size=80 --stack_size=80 -i"C:/ti/ccs810/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccs810/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccs810/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="user5072621_MSP430G2553_linkInfo.xml" --use_hw_mpy=none --rom_model -o "user5072621_MSP430G2553.out" "./main.obj" "../lnk_msp430g2533.cmd"  -llibc.a 
    <Linking>
    remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 1 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 2 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 3 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    Finished building target: "user5072621_MSP430G2553.out"
     
    
    **** Build Finished ****
    


    Then I started C++ programming within main.cpp:
    #include <msp430.h> 
    
    class Clock {
        private:
             // data
             int id;
             double ticks;
             int microsecond;
             int millisecond;
             int second;
             int minute;
             int hour;
             int day;
             int month;
             int year;
             int century;
             int millenium;
    
        public:
            // methods
            Clock(int newId);  // Constructor
            ~Clock();          // Destructor
    };
    
    /* Global clock objects */
    Clock cl0(0);  /* idle loop clock */
    Clock cl1(1);  /* periodic clock, period = 1 ms */
    Clock cl2(2);  /* periodic clock, period = 1 sec */
    Clock cl3(3);  /* task clock */
    Clock cl4(4);  /* task clock */
    
    /**
     * main.cpp
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    	return 0;
    }
    
    
    /*
     * Clock methods
     */
    Clock::Clock(int newId)
    {
        id = newId;
        ticks = 0;
        microsecond = 0;
        millisecond = 0;
        second = 0;
        minute = 0;
        hour = 0;
        day = 19;
        month = 8;
        year = 10;
        century = 20;
        millenium = 0;
    }
    
    Clock::~Clock()
    {
    }
    

    The code above compiler without errors.

    YOU:
    <<< my question is i need to declare c++ constructor & Deconstructor
    See examples above. Do not waste time waiting for answers, just try.

    <<< how to write or declare , not supply no useful information.
    Information provided by me would be useful for you later on.

    <<< is is difficult to find c++ on css IDE , I think that css is a terrible IDE software and not friendly.
    Just 2-3 google queries and you get what you need. Also, queries on e2e are very helpful.

    <<< this is simply to declare c++ constructor on Arduino IDE , but css is terrible and difficult.
    Arduino gives you C++ interface. On CCS you have started with C and did not converted that to C++.

    <<< if I want to use ccs , i need to read vast complicated information, could u tell me how to do direct and simply?
    Arduino is for kids. CCS is for professionals.
    Go to CCS manual, learn list of content and subtopics. That would help to know what to read if needed.
    Try and ask if you do not understand results of you tries.

    <<< I am very Anxious write code
    Anxious, you have said.
    Your LiquidCrystal.h file contains:

    #include "inttypes.h"
    #include "Print.h"

    That is the place where real issues could start.

    Probably it would be easier for you to port your Arduino code to Energia platform then to convert everything to pure C/C++.

  • Hello user5072621 ,

    I see that you did some progress and I guess that you were able to compile C++.
    If your C/C++ linking issue is fixed, please mark this thread as Recolved.
  • It is difficult to tell what went wrong with your C++ build.  But the errors do not look specific to CCS or the TI MSP430 compiler.  Try building your C++ code on your PC, using an IDE and compiler you know well.   I suspect you will find similar errors.

    Thanks and regards,

    -George

  • Code Composer Studio (CCStudio or CCS) is an integrated development environment (IDE) to .... The XDS510-class and the more advanced XDS560-class emulators are supported across all releases, but the ... Code Composer Studio at TI website; Code Composer Studio wiki · Code Composer Forum at DSPRelated.com
  • user5072621,

    please mark this post as Resolved because our friends loose time reading and answering to it!
  • user5072621 said:

    Part Number: MSP430G2553

    Tool/software: Code Composer Studio

    Hi guys,

    I am try to find lcd1602 library ,but i can't find great library for use.

    So i want to transplant Arduino lcd library to msp430G2553.

    But some question i meet. Discord

    My code composer can compiler for arduino library(which is i change the code)

    but i write the command one for "LiquidCrystal lcd(1,2,3,4,5,6);" ,then some mistake rebuild.

    like picutre iTunes

    and my library is upload. 

    (Please visit the site to view this file)(Please visit the site to view this file) Adobe Reader

    this is i am try to transplant it is not complete modify the code . plze help me

    Part Number: TMS570LS3137 Tool/software: Code Composer Studio When i am trying to compile the complete project which contains C-Source files along with the ASM files But i am not able to compile only the ASM files but the c-source files are compiled. Below are the Error details coming for the ASM files Error Description: Description Resource Path Location Type [E0000] Unrecognized special character abc.asm /Shetty/02_SW/SRC line 18 C/C++ Problem Description Resource Path Location Type [E0002] Illegal mnemonic specified abc.asm /Shetty/02_SW/SRC line 1 C/C++ Problem Compiler Used: Ti v15.12.4 LTS Code Composer Studio Version: 7.3.0.00019 Regards, Narasimha Setty Bapur

  • Mazenn,

    what do you need?