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.
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
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
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
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
Hi
Thanks for you reply.
Please find attached project which replicates above mentioned error.
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.
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
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?
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
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.
Hi
Thank you for reply.After upgrading this is working fine.
Thank You very much.
Regards
Shrikant