• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Development Tools » TI C/C++ Compiler » TI C/C++ Compiler - Forum » #pragma interrupt function parameters corrupt issue tms470 compiler
Share
TI C/C++ Compiler
  • Forum
Options
  • Subscribe via RSS

Forums

#pragma interrupt function parameters corrupt issue tms470 compiler

This question is answered
Shrikant S
Posted by Shrikant S
on May 03 2012 03:54 AM
Prodigy160 points

Hello,

I have a function with 8  parameters.Futher I have used #pragma INTERRUPT for enabling interrupt service routines.With this on making the function call the function parameters are getting corrupted after the 4th parameter.Without #pragma INTERRUPT  everything works fine.PLease help me correct this issue.Is there any special setting which i have to make in the CCS???

If the definition of the function is moved above the #pragma interrupt  (used for defining interrupt subroutines) then again the function parameters are proper and everything works fine.This is a strange behaviour can you help me fix this soon.

Regards

Shrikant

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • George Mock
    Posted by George Mock
    on May 03 2012 16:22 PM
    Guru51290 points

    I'm confused.  An interrupt function cannot accept any parameters, or return any result.  I get an error message when I try to pass arguments to a #pragma INTERRUPT function.  Please show an example of how you are using #pragma INTERRUPT.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question.
    The Compiler Wiki answers most common questions.
    Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 04 2012 00:19 AM
    Prodigy160 points

    Hi George 

    Thanks for reply.I am not passing any arguments to interrupt function.There is a non interrupt function(Normal Function)  which takes 8 arguments. but with #pragma INTERRUPT statement in source code,last 4 parameters are corrputed.

    Below is a example.

     // This is where we have added #pragma INTERRUPT statement in the source code so this is the interrupt function.

    #pragma INTERRUPT(sciHighLevelInterrupt, IRQ)
    void sciHighLevelInterrupt(void)
    {
    uint32_t vec = sciREG->INTVECT0;

    switch (vec)

    {
    case 1:
    sciNotification(sciREG, SCI_WAKE_INT);
    break;
    case 3:
    sciNotification(sciREG, SCI_PE_INT);
    break;

    }

    }

    //Normal Function

    static int Check_Parameter (int value1,int value2,char * name,char * value_string,char sign,int wind_power,int compare,int convert_ok,char * actual_string)

    {

       //Logical statements

     return ( 0);

    }

    void main(void)

    { 

    int x;

    x = Check_Parameter(1,2,"3","4",'G',5,6,7,"8");

    x = x + 1; //dummy statement

    } 

    Case 1: If we keep the same source code as like above,from main when control enters in function Check_Parameter  ,the 5th parameter onwards  ( i.e char sign,int wind_power,int compare,int convert_ok,char * actual_string) are getting corrupted.We dont not get correct values what we have passed from main function.

    Case 2: If we copy the definition of function Check_Parameter before interrupt function means before #pragma INTERRUPT statement,all values are correctly taken in Check_Parameter function.

    If we look at the assembly source code for both cases,they are differenent. Really not sure what does it make difference to compiler when we add the function definition before #pragma INTERRUPT function.

    Hope you are clear now.Please let me know what could be the issue.

    Regards

    Shrikant 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on May 04 2012 09:08 AM
    Mastermind40550 points

    I cannot reproduce this problem.  What command-line options are you using?  What version of the compiler (not the CCS version).  How do you know the parameters are corrupt?  Are you determining this by looking at the expression from within CCS?

    Your test case doesn't compile without some modifications.  Could you post a complete, compilable test case that demonstrates the problem?

    Here is the code I'm using to test the issue:

    #include <stdio.h>
    #include <stdint.h>
    
    struct x { int INTVECT0; } object = { 1 }; 
    struct x *sciREG = &object;
    
    #define SCI_WAKE_INT 0
    #define SCI_PE_INT 1
    
    void sciNotification(struct x *a, int b) { }
    
    #pragma INTERRUPT(sciHighLevelInterrupt, IRQ)
    void sciHighLevelInterrupt(void)
    {
        uint32_t vec = sciREG->INTVECT0;
    
        switch (vec)
        {
            case 1:
            sciNotification(sciREG, SCI_WAKE_INT);
            break;
            case 3:
            sciNotification(sciREG, SCI_PE_INT);
            break;
    
        }
    }
    
    //Normal Function
    
    static int Check_Parameter (int value1,
                                int value2,
                                char * name,
                                char * value_string,
                                char sign,
                                int wind_power,
                                int compare,
                                int convert_ok,
                                char * actual_string)
    
    {
        printf("%d %d %s %s %c %d %d %d %s\n",
               value1, value2, 
               name, value_string, 
               sign,
               wind_power, compare, convert_ok,
               actual_string);
    
        return ( 0);
    }
    
    void main(void)
    { 
        int x;
        x = Check_Parameter(1,2,"3","4",'G',5,6,7,"8");
        x = x + 1; //dummy statement
    }

    The output:

    1 2 3 4 G 5 6 7 8
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 09 2012 02:12 AM
    Prodigy160 points

    Hi

    Thanks for you reply.


    Please find attached project which replicates above mentioned error.


    4657.Test_Project.zip

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on May 09 2012 09:04 AM
    Mastermind40550 points

    I compiled the test case you posted, but I was not able to find any problems. How do you know the arguments are corrupted?  What symptom do you see?

    Please don't answer "yes" to "did this answer the question" until you have a solution to your problem.   When you answer "yes" to "did this answer the question", this means that the thread will be considered resolved, which is not the case yet.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 15 2012 00:48 AM
    Prodigy160 points

    Hi

    Have you tried running on Simulator or Target?

    Corruption of data means... I am not getting correct prints.. I am suppose to get as 1,2,"3","4",'G',5,6,7,"8" but I do not get like this.

    When I debugged,i found that last 4 parameters does not contain the same values after entering into the function.Please find attached screen shot.

    Regards

    Shrikant

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Manoj R94504
    Posted by Manoj R94504
    on May 15 2012 01:06 AM
    Prodigy215 points

    Hi,

    I can reproduce this problem  

    I will attach the snapshots u can check these snapshots for more information on the error

      

    If you need further information we can have a webex on this.

    Manoj R

    (a0131910)

    Safety MCU Software

    TII Bangalore

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on May 15 2012 07:24 AM
    Mastermind40550 points

    Please show me where in sci.c you are including stdio.h.  At compile time, do you get a warning that says that printf is implicitly defined?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 15 2012 08:26 AM
    Prodigy160 points

    Hi

    I have not used stdio.h any where in sci.c file and not getting any warning for printf.

    I tried commenting printf function in Check_Parameter function but still data is getting corrputed.

    The issue here is #pragma INTERRUPT is added above this function,So compiler is considering all functions below #pragma INTERRUPT statement are interrupt functions.#pragma is not getting closed ( some thing i can say) because if I copy Check_Parameter function above #pragma INTERRUPT statement,this function works correctly.

    Regards

    Shrikant

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on May 15 2012 10:39 AM
    Suggested Answer
    Mastermind40550 points

    Okay, I've figured this out.  The short answer is to upgrade to 4.9.3 or better.

    The key was figuring out what version of the compiler you are using; I still don't know for sure, but I believe you are using 4.9.1.

    In version 4.9.3, SDSCM00042653 was fixed.  This bug involves VFP registers being saved unnecessarily, which was thought to be a benign performance problem.  The symptom is, as you suggest, that every function that comes after an interrupt function will unnecessarily save FPSCR and FPEXC.  It is only actually necessary to save these registers in an interrupt function.  The problem is that when these registers are mistakenly saved in a non-interrupt function, the compiler fails to take the stack space for these registers into account when computing the stack address of incoming arguments.  The symptom is that every argument that is passed on the stack would appear corrupted.

    ARM bug floating point interrupt
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 15 2012 11:22 AM
    Prodigy160 points

    Hi

    Thanks for reply.Yes you are correct.I am using 4.9.1 .Please find attached screen shot.

    Can you please tell me how to upgrade to version 4.9.3 version?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on May 15 2012 12:00 PM
    Verified Answer
    Verified by Shrikant S
    Mastermind40550 points

    http://processors.wiki.ti.com/index.php/Updating_CCSv5

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Shrikant S
    Posted by Shrikant S
    on May 16 2012 01:47 AM
    Prodigy160 points

    Hi

    Thank you for reply.After upgrading this is working fine. 

    Thank You very much.

    Regards

    Shrikant

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use