中级会员
 
- 积分
- 453
- 金钱
- 453
- 注册时间
- 2013-5-23
- 在线时间
- 47 小时
|

楼主 |
发表于 2013-6-3 22:28:25
|
显示全部楼层
回复【5楼】ofourme:
---------------------------------
怎么解决这个问题呢 刚好有个类似的例子 我的程序和这个差不多 但是大了点 不方便传
现在的问题是:主页面和菜单页面互相切换,主页面一个按键,按下该按键切换到菜单页面;菜单页面有9个按键,按下菜单页面的返回按键切换到主页面,
这样互相切换个242次的时候该任务就堆栈溢出死掉了,进了HardFault_Handler中断灯亮了:(当把堆栈改大掉,切换次数就可以多一点)
void HardFault_Handler(void)
{
  Fout(13)=1; //灯会亮
while (1);
}
第一个主页面如下:
void Home_Page(void) //开始首页
{
BUTTON_Handle hButton;
u8 Key;
GUI_Clear();
Home_Page_BIN=1;
GUI_SetBkColor(GUI_LIGHTBLUE);
hButton = BUTTON_Create( 700, 370, 95, 63, 1, BUTTON_CF_SHOW );
BUTTON_SetBitmapEx(hButton,0,&bmbackindexpage,0,0);
do{
Key = GUI_WaitKey();
switch (Key)
{
case 0: break;
case 1: BUTTON_Delete(hButton);Home_Page_Fig=0;Menu_Page();break; //这里切换到第二个页面
default:break;
}
}while ((Key != 'N') && (Key!=GUI_ID_CANCEL) && (Key!=0));
BUTTON_Delete(hButton);
}
第一个菜单页面如下:
void Menu_Page(void)
{
BUTTON_Handle men_Button[9];
u8 index_key,i;
GUI_Clear();
men_Button[0]= BUTTON_Create( 110, 90, 99, 119, 10, BUTTON_CF_SHOW );
men_Button[1]= BUTTON_Create( 270, 90, 99, 119, 11, BUTTON_CF_SHOW );
men_Button[2]= BUTTON_Create( 430, 90, 98, 119, 12, BUTTON_CF_SHOW );
men_Button[3]= BUTTON_Create( 590, 90, 95, 117,13, BUTTON_CF_SHOW );
men_Button[4]= BUTTON_Create( 110, 250, 96, 124, 14, BUTTON_CF_SHOW );
men_Button[5]= BUTTON_Create( 270, 250, 99, 118, 15, BUTTON_CF_SHOW );
men_Button[6]= BUTTON_Create( 430, 250, 98, 120, 16, BUTTON_CF_SHOW );
men_Button[7]= BUTTON_Create( 700, 370, 95, 63, 17, BUTTON_CF_SHOW );
men_Button[8]= BUTTON_Create( 590, 250, 96, 124, 18, BUTTON_CF_SHOW );
do{
index_key = GUI_WaitKey();
switch (index_key)
{
case 10: break; //
case 11: break;
case 12: break;
case 13:break;
case 14: break;
case 15:break;
case 16: break;
case 17: for(i=0;i<9;i++) //按下此返回按钮时回到主页面
{
BUTTON_Delete(men_Button);
} Home_Page();break; //回到主页面
case 18: break;
default:break;
}
}while ((index_key != 'N') && (index_key!=GUI_ID_CANCEL) && (index_key!=0));
for(i=0;i<9;i++)
{
BUTTON_Delete(men_Button);
}
} |
|