SP debug info incorrect

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SP debug info incorrect

跳至解决方案
3,081 次查看
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.
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,386 次查看
CompilerGuru
NXP Employee
NXP Employee
To switch off the optimization, use -onf.

Daniel

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,386 次查看
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 项奖励
回复
1,386 次查看
Seitec
Contributor III
yes sorry, i forgot on it Thank you very much.
0 项奖励
回复
1,387 次查看
CompilerGuru
NXP Employee
NXP Employee
To switch off the optimization, use -onf.

Daniel
0 项奖励
回复
1,386 次查看
Seitec
Contributor III
Thank you. where I can write this -onf please?
0 项奖励
回复
1,386 次查看
CompilerGuru
NXP Employee
NXP Employee
In the "Command line arguments" field in the "Compiler for HC??" preferences of the project Settings.

Daniel
0 项奖励
回复