SP debug info incorrect

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SP debug info incorrect

Jump to solution
3,071 Views
Seitec
Contributor III
Hello I have this code:


int n = 0;
void interrupt 38 receive_can(void){

unsigned char count;

Rx_Table[n].DLC=(CAN0RXDLR & 0x0F); /*prijata delka*/

for(count = 0; count < Rx_Table[n].DLC; count++){
Rx_Table[n].Data[count] = *(&CAN0RXDSR0 + count); /*kopirovani dat*/
}

CAN0RFLG = 0x01; /*nastaveni RXF dalsi zprava muze byt prijata*/
n++;
}

/******************************************************/
but if I would like debug there is warming SP debug info incorrect...
But if I arrange code (where int n = 0; is inside the function):
/*****************************************************/
void interrupt 38 receive_can(void){

unsigned char count;
int n = 0;

Rx_Table[n].DLC=(CAN0RXDLR & 0x0F); /*prijata delka*/

for(count = 0; count < Rx_Table[n].DLC; count++){
Rx_Table[n].Data[count] = *(&CAN0RXDSR0 + count); /*kopirovani dat*/
}

CAN0RFLG = 0x01; /*nastaveni RXF dalsi zprava muze byt prijata*/
n++;
}

It work properly without warmings but I need "n" as global. Is it mistake if I have "n" as global? Can I Switching off this optimization? Or I have mistake in code?

Thank you very much.
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,376 Views
CompilerGuru
NXP Employee
NXP Employee
To switch off the optimization, use -onf.

Daniel

View solution in original post

0 Kudos
Reply
5 Replies
1,376 Views
Lundin
Senior Contributor IV
I'm sure you know that "n" must be volatile if it is global. Otherwise you are introducing subtle but critical bugs in your program.
0 Kudos
Reply
1,376 Views
Seitec
Contributor III
yes sorry, i forgot on it Thank you very much.
0 Kudos
Reply
1,377 Views
CompilerGuru
NXP Employee
NXP Employee
To switch off the optimization, use -onf.

Daniel
0 Kudos
Reply
1,376 Views
Seitec
Contributor III
Thank you. where I can write this -onf please?
0 Kudos
Reply
1,376 Views
CompilerGuru
NXP Employee
NXP Employee
In the "Command line arguments" field in the "Compiler for HC??" preferences of the project Settings.

Daniel
0 Kudos
Reply