求助,F4板子跑UCOSIII+0.96寸TFT屏遇到问题。

2019-07-20 03:58发布

本意是想实现TFT屏的显示切换的。之前只创建了单个任务,循环做彩屏的切换,一切正常。现在创建了两个任务,增加的一个任务只不过是读取按键值而已,然后经过测试发现,在多任务下一旦执行到了某个特定的函数的时候就会进入hardfault_handler 中断,这个函数没有进行与TFT屏的SPI通讯,全都是对一些数组的计算和赋值而已,只不过这些数组有些大。任务堆栈大小增大了也没用。求帮忙看看你这段代码有什么问题吗?明明单任务的时候能正常运行的。


extern  unsigned char gImage_AddUser[4608];
extern  unsigned char gImage_UserArray[4608];
extern  unsigned char gImage_CheckUser[4608];
unsigned char *Menu_icon[5] = {0,gImage_AddUser,gImage_CheckUser,gImage_UserArray,0};
extern const unsigned char gImage_LeftArrow[512];
extern const unsigned char gImage_RightArrow[512];
void RefreshMainInterface(u8 i)
{
        u32 x,y;
        u16 temp; //缓存
        u32 x0 = 0,y0 = 0;
        u32 cout;
        for(cout = 0; cout < 15360; cout++)
        {
                Array_Temp[cout] = gImage_pixel_main_interface[cout];
        }

        y0 = 0;
        x0 = 0;
        if(Menu_icon != 0)
        {
                //先更新40*40小图标
                for(y = 0; y < 48 ;y++)
                {
                        for(x = 0; x < 48 ;x++)
                        {
                                if( (x%6) == 0)        x++;
                                if( (y%6) == 0) y++;
                                temp = ((unsigned short int)(Menu_icon [(y*48+x)*2]) << 8) | ((unsigned short int)(Menu_icon [((y*48+x)*2)+1]));
                                if(temp != 0x0000)
                                {
                                        Array_Temp[((y0+8)*160 + x0)*2] = (u8)(temp>>8);
                                        Array_Temp[((y0+8)*160 + x0)*2 + 1] = (u8)temp;
                                }
                                x0++;                       
                        }
                        y0++;
                        x0 = 0;
                }
                //更新左箭头
                for(x=0;x<16;x++)
                {
                        for(y=0;y<16;y++)
                        {
                                temp = ((unsigned short int)(gImage_LeftArrow[(y*16+x)*2]) << 8) | ((unsigned short int)(gImage_LeftArrow[((y*16+x)*2)+1]));
                                if(temp != 0x0000)
                                {
                                        Array_Temp[((y+16)*160 + x + 40)*2] = (u8)(temp>>8);
                                        Array_Temp[((y+16)*160 + x + 40)*2 + 1] = (u8)temp;
                                }               
                        }
                }
        }


        //再更新大图标
        for(y = 0; y < 48 ; y++)
        {
                for(x = 0; x < 48 ; x++)
                {
                        temp = ((unsigned short int)(Menu_icon[i + 1][(y*48+x)*2]) << 8) | ((unsigned short int)(Menu_icon[i + 1][((y*48+x)*2)+1]));
                        if(temp != 0x0000)
                        {
                                Array_Temp[(y*160 + x + 56)*2] = (u8)(temp>>8);
                                Array_Temp[(y*160 + x + 56)*2 + 1] = (u8)temp;
                        }
                }
        }

        //更新小图标
        y0 = 0;
        x0 = 0;
        if(Menu_icon[i + 2] != 0 )
        {
                //更新右箭头
                for(x=0;x<16;x++)
                {
                        for(y=0;y<16;y++)
                        {
                                temp = ((unsigned short int)(gImage_RightArrow[(y*16+x)*2]) << 8) | ((unsigned short int)(gImage_RightArrow[((y*16+x)*2)+1]));
                                if(temp != 0x0000)
                                {
                                        Array_Temp[((y+16)*160 + x + 104)*2] = (u8)(temp>>8);
                                        Array_Temp[((y+16)*160 + x + 104)*2 + 1] = (u8)temp;
                                }               
                        }
                }
                for(y = 0; y < 48 ;y++)
                {
                        for(x = 0; x < 48 ;x++)
                        {
                                if( (x%6) == 0)        x++;
                                if( (y%6) == 0) y++;
                                temp = ((unsigned short int)(Menu_icon[i + 2][(y*48+x)*2]) << 8) | ((unsigned short int)(Menu_icon[i + 2][((y*48+x)*2)+1]));
                                if(temp != 0x0000)
                                {
                                        Array_Temp[((y0+8)*160 + x0 + 120)*2] = (u8)(temp>>8);
                                        Array_Temp[((y0+8)*160 + x0 + 120)*2 + 1] = (u8)temp;
                                }
                                x0++;                       
                        }
                        y0++;
                        x0 = 0;
                }
        }
}

0条回答

一周热门 更多>