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.

How to add the interrupt for TI RTOS based application

Other Parts Discussed in Thread: MSP430F5659, SYSBIOS, MSP430F5529, MSP430F6659

Hi,

I want to add the ADC12 interrupt to my TI RTOS based application for MSP430F5659 controller, But i got error while adding ADC12 interrupt,

Error:
#10056 symbol "__TI_int54" redefined:    C/C++ Problem

Please let me know how to resolve the interrupt addition to TI RTOS application.

Nitesh

  • Nitesh,

    SYS/BIOS (the kernel that's part of TI-RTOS) for the MSP430 series will construct an interrupt vector for every interrupt on the particular part.  Interrupts that have been configured in the .cfg file will result in an interrupt vector definition that calls the configured ISR, while all the unconfigured interrupts will result in an interrupt vector stub (that spins, by default).  If you have your own
        #pragma vector = 54
    in your application then that is probably why __TI_int54 is getting redefined (I'm somewhat guessing here, as I don't know the source of that symbol), since SYS/BIOS will also use that.

    Have you created the Hwi instance for the ADC12 device interrupt in your .cfg file?  This is the way to program ISRs in SYS/BIOS.  Doing so won't solve this issue, since SYS/BIOS generates an interrupt vector for *all* interrupts regardless of the interrupts configuration status, but it's a needed step for using SYS/BIOS.

    Here are some links that might help:

    http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430

    The above web page contains an example of configuring an Hwi instance in your .cfg file:
    var Hwi = xdc.useModule('ti.sysbios.family.msp430.Hwi');
    Hwi.create(53, '&hwiFxn53');

    http://processors.wiki.ti.com/index.php/Creating_TI-RTOS_2.10_Projects_for_Other_MSP430_Devices

    Regards,

    - Rob

  • Hi Rob,

    Thanks for the reply, i am able to resolve the linker error, i added the interrupt routine in HwiFunc.c file and .cfg added the script as below

    "var hwi2Params = new Hwi.Params();

    hwi2Params.instance.name = "hwi2";

    hwi2Params.arg = 0;

    Program.global.hwi2 = Hwi.create(54, "&ADC", hwi2Params);"

    Now i am able to compile and link, i will test it.

    I have one more question - Can i invoke the taskA from taskB whenever required? Or i need to use IPC mechanism or SEM/Events? Please guide me with regards to TI RTOS

    -Nitesh 

  • Rob,
    How to make the task to run at periodic intervals in TI RTOS?
    -Nitesh
  • Rob,
    How to make the task to run at periodic intervals in TI RTOS?
    -Nitesh
  • Nitesh Padiyar52 said:
    i am able to resolve the linker error, i added the interrupt routine in HwiFunc.c file

    Are you saying you modified HwiFunc.c in <project>/src/sysbios?  That is a generated file which could be overwritten by a new build.  You should put your ADC12 ISR in one of your own source files, and HwiFunc.c will be modified according to your .cfg Hwi configuration.

    Nitesh Padiyar52 said:
    I have one more question - Can i invoke the taskA from taskB whenever required? Or i need to use IPC mechanism or SEM/Events? Please guide me with regards to TI RTOS

    You will need post some sort of synchronization module to cause execution to transfer from taskB to taskA.  Semaphore is a good synchronization mechanism.  With Semaphore, and assuming that taskA is higher priority than taskB, taskA can do
        Semaphore_pend(taskASem, BIOS_WAIT_FOREVER);
    which blocks taskA until the Semaphore is posted (assuming the Semaphore was created with a count of 0, or has a count of 0 when the Semaphore_pend() is called).  Then when taskB is ready to relinquish control, it calls
        Semaphore_post(taskASem);
    which will cause the higher-priority taskA to run, presumably until it blocks again at that Semaphore_pend().

    If taskA and taskB are of equal priority then calling Task_yield() will bounce between the 2 tasks (assuming there are no other tasks at the same priority as taskA and taskB).

    IPC, which traditionally stands for InterProcessor Communication, is not utilized between threads (Tasks) that are part of the same application on a single CPU.

    Regards,

    - Rob

  • Nitesh Padiyar52 said:
    How to make the task to run at periodic intervals in TI RTOS?

    This question belongs in a new thread since it doesn't relate to this thread's title.  Can you please post the question in a new post with an appropriate title?

    However, I will answer here so you get your answer more quickly, and I will also post the same answer in your new thread (if you so choose to create one)...

    The Task_sleep() API can be used to cause your Task to block and then wakeup after the sleep interval.

    Alternatively, you could setup a periodic Timer object to run at your specified period, and the Timer object's function can post a Semaphore upon which the Task is blocked.  This is probably better than the Task_sleep() solution since the Task_sleep() solution doesn't account for the time that the Task was running in between Task_sleep() calls.

    Regards,

    - Rob

  • Hi Rob,

    Thanks for the explaining. I am clear with your answer. Will come back if any problem.

    Nitesh 

  • Hi Rob,

    As you told i need add my routine separately and that will be called from Hwifunc.c file, which will created once i create a new HW interrupt from visual representation/ adding .cfg script correct?

    For the second part i am clear on task synchronization and i will test and confirm this.

    For the interrupt routine i will test and let you know.

    thanks

    Nitesh 

  • Nitesh Padiyar52 said:
    As you told i need add my routine separately and that will be called from Hwifunc.c file, which will created once i create a new HW interrupt from visual representation/ adding .cfg script correct?

    Yes, that is correct, when you create an Hwi instance in your .cfg script (either through the GUI or manually by adding to the .cfg source) then the HwiFunc.c will contain a vector that calls your Hwi function.

    Regards,

    - Rob

  • Hi Rob,

    I am able to make the ADC12 working with TIRTOS using interrupt. Thanks for the help.

    Still many things i need to integrate now, I need some help in USB CDC for the receive packet of unknown bytes, that means PC application will send packet of different sizes. I am looking at the ex:"usbserialdevice_MSP_EXP430F5529LP_TI_MSP430F5529". It receives 31 bytes constantly, but i need random bytes receive, any thought on this please share.

    For this ex. i am able to receive, if i make changes like function shown below.

    uint8_t USBCDC_handleDataReceived(uint8_t intfNum)

    {

      bCDCDataReceived_event = TRUE;

      return TRUE; //return TRUE to wake up after data was received

    }

    which is called from usb interrupt function on receive of data, and flag "bCDCDataReceived_event" is used while handling rx task i am not able to receive any thing. control always stay in  "

    USBCDCD_waitForConnect(BIOS_WAIT_FOREVER);"  function.

    Please correct if i am doing wrong. Suggest if you know how to address this issue.

    I want random data packet receive and then as per packet i want jump to some other task.

  • It will take me a little while to research this issue with some colleagues since I don't know the USBCDC module at all.

    Regards,

    - Rob
  • Hi Rob,

    The USB issue of Receive got resolved, changes done shown below,

    if(bCDCDataReceived_event) // Some data is in the buffer; begin receiving a command

    {

     //readBytes = USBCDCD_receiveData((uint8_t *)RxPacket, 31, BIOS_WAIT_FOREVER);

    readBytes = USBCDCD_receiveData((uint8_t *)RxPacket, 31, 100);

    bCDCDataReceived_event = FALSE;

    }

    here for the USBCDCD_receiveData function changed the 3rd parameter from BIOS_WAIT_FOREVER to 100.

    Thanks again......

    One more help any example available for the periodic task, HW switch interrupt? please share the link

     

    -Nitesh

  • Hi Rob,

    I have one more question regarding TI RTOS driver part.

    Drivers file are found @ "C:\ti\tirtos_msp43x_2_14_03_28\packages\ti\drivers" ,

    For Ex.
    I am not seeing GPIO related function definition.
    extern void GPIO_toggle(unsigned int index);
    extern void GPIO_write(unsigned int index, unsigned int value);

    Are they library file? If so how to compile required driver library files so that unwanted drivers files are eliminated?

    In the above driver path i am seeing all the drivers but i don't need all of them for my board.

    In one word compiling only required files for the board.

    Just for info -

    I added the library path for MSP430F5659 in CCS - "Projects->Properties-> MSP430 Linker-> File Search Path" while porting the example project from MSP430F5529LP to MSP430F5659.

    i.e. "${COM_TI_RTSC_TIRTOSMSP430_INSTALL_DIR}/products/MSPWare_2_00_00_40c/driverlib/ccs-MSP430F6659/ccs-MSP430F6659.lib" after creating the library file using " gmake.exe -f tirtos.mak drivers".


    One last thing are these library files add lot to memory footprint??????

    Please help me.

    -Nitesh
  • Hi Rob,
    One more question, For ex project MSP430F5529LP which i ported to MSP430F6659 still project platform shows MSP430F5529 in .cfg file

    PlatformName in .cfg file path:
    TIRTOS->Products->SYSBIOS->system->Program ------ ti.platforms.msp430:MSP430F5529,

    How this is not changed since i have changed target settings in project properties->General while building the project for MSP430F6659 as well as in RTSC i changed platform as "ti.platforms.msp430:MSP430F6659" from "ti.platforms.msp430:MSP430F5529".

    Please let me know whether this need to be changed some where else also?

    -Nitesh
  • I'm glad you were able to solve your issue with USB variable data.

    Nitesh Padiyar52 said:
    One more help any example available for the periodic task, HW switch interrupt? please share the link

    No, we don't have any example such as this, but I can offer some guidance...

    A periodic Task can be achieved using a Clock instance and a Semaphore.

    The Clock instance would be created with a period that represents the time interval upon which you want your Task to run.  A Clock instance's period is specified in "ticks", and the Clock module is configured with a "tick period", which is typically 1 millisecond (achieved with a Clock_tickPeriod of 1000 microseconds).  If you wanted a task period of 10 ms, create the Clock instance with a period of 10.  The Clock instance's function would simply post a Semaphore.

    The Semaphore instance would be created with either a count of 0 or 1, and I would suggest a binary semaphore.

    Here's some pseudo-code:

    taskFunction()
    {
        while (run) {
            Semaphore_pend(clockSem, BIOS_WAIT_FOREVER);
            do task work here...
        }
    }

    clockFunction()
    {
        Semaphore_post(clockSem);
    }

    The task work must execute in less time than the clockFunction period.

    The initial value of the clockSem can be either 0 (not posted) or 1 (posted).  Considering the above Task code, the difference would be:
        - when created with count of 0, task will block immediately before doing its work and wait for the next clockFunction() post
        - when created with count of 1, task will run through Semaphore_pend() without blocking, do its work, and then block until the next clockFunction() post

    By using a binary semaphore, multiple clockFunction() posts will not stack up if the task hasn't been able to run in between clockFunction() invocations (due to being held off by a higher priority task).  In other words, if the clockFunction() is invoked twice without the taskFunction() getting a chance to run, the taskFunction() will run only once even though two or more ticks happened.  However, using a counting semaphore, the posts will stack up and would allow the task to "catch up" and loop multiple times without blocking in case it didn't get a chance to run in between clockFunction() invocations (i.e., for the case where the task loop must run for every clockFunction() invocation, even if delayed longer than the period).

    Regards,

    - Rob

  • Nitesh Padiyar52 said:
    For Ex.
    I am not seeing GPIO related function definition.
    extern void GPIO_toggle(unsigned int index);
    extern void GPIO_write(unsigned int index, unsigned int value);

    For your part these are defined in tirtos_msp43x_2_14_03_28/packages/ti/drivers/gpio/GPIOMSP430.c.

    Nitesh Padiyar52 said:
    Are they library file? If so how to compile required driver library files so that unwanted drivers files are eliminated?

    A library named drivers_MSP430F5969.ae430X is created that contains all the driver object files.  However, since it's a library, only object files from the library that contain symbols which you reference are pulled in.  There is no need to compile the library with a smaller set of files - if you don't reference a symbol from one of the object files in the library, that object file won't get pulled in.

    Nitesh Padiyar52 said:
    One last thing are these library files add lot to memory footprint??????

    As I said above, a library in itself adds nothing to your memory footprint.  Object files contained in the library add memory footprint, and the whole object file will be linked in if you reference any symbol defined within that object file.  The key point here is that if your application references a symbol then the object file that defines that symbol will be pulled from the library and linked to your application.  To reduce memory footprint you would want to eliminate references to symbols that you don't need.  The TI-RTOS driver examples typically contain a <Board>.c file, where "Board" for you is MSP_EXP430F5659.c, which is part of your CCS project.  This file is a "reference design" for all the driver examples, and therefore it contains things that you might not need.  It is intended that the user (i.e., you) will modify this file to suit your needs (and the accompanying MSP_EXP430F5659.h file).

    It would be helpful to look at your .map file to see what object files were pulled from what libraries.

    Regards,

    - Rob

  • Hi Rob,

    Thanks for the input. I am facing some problem with my integration.

    I have two task USB and ADC.

    On receiving data over USB i am invoking ADC task. Now on ADC task needed only when i have new data arrives. For this i have created Events using semaphore to handle, so on first reception and it works but how to stop this task from running after sending data using USB?

    In my case ADC task runs continuous, i don't to know how to make it invoked or executed on USB data reception on next time. Please guide.

    One more thing if USB task is running and my board is connected to PC application, Whether disconnection of cable is handled in USB CDC application of "usbserialdevice_MSP_EXP430F5529LP_TI_MSP430F5529" . If  not how i can achieve this?

    Nitesh

  • Hi Nitesh,

    Can you please post this to a new thread?  It helps us track progress on a question or issue and make sure it gets answered promptly.

    Regards,

    - Rob