STM32异常进入HardFault

在练习UCOS时,程序运行到OSStart(&err)函数时进入HardFault异常,起初以为是栈溢出,更改了任务栈的大小,但还是不行
然后在网上查HardFault代码定位方法,使用以下方法

img

然后使用show code at address定位到了

img

img

只是增加了一个任务蓝牙修改时间任务

void task3(void *parg)
{

    //OS_ERR err;

//    OS_MSG_SIZE msg_size;
//    
//    uint32_t year=0,month=0,day=0,week=0;
//    
//    //,hour=0,Minutes=0,Seconds=0
//    
//    char *p_usart3_send;
//    
//    char *q = NULL;
    
    //printf("task3 is create ok\r\n");

    while(1)
    {
//        
//        //等待消息队列-来源于串口数据
//        p_usart3_send=OSQPend(&g_queue_usart3,0,OS_OPT_PEND_BLOCKING,&msg_size,NULL,&err);
//        
//        if(p_usart3_send && msg_size)
//        {
//        
//            //printf("%s\r\n",p_usart3_send);
//            
//            //进行数据处理
//            if(strstr((const char *)p_usart3_send,"DATE"))
//            {
//                //提取数据
//                q=strtok((char *)p_usart3_send,"-");            //DATE
//                
//                
//                q=strtok(NULL,"-");            //year
//                
//                
//                //printf("q=%s\r\n",q);
//                //字符串转换为整型
//                year = atoi(q)-2000;                //2019” -> 2019,2019-2000=19    
//    
//                //10进制转换为16进制,19->0x19
//                year=(year/10)*16+year%10;
//                                
//                
//                q=strtok(NULL,"-");            //month
//                
//                
//                //字符串转换为整型
//                month = atoi(q);                //4” -> 4
//                
//                //10进制转换为16进制
//                month=(month/10)*16+month%10;
//        

//                q=strtok(NULL,"-");            //day
//                
//                
//                //字符串转换为整型
//                day = atoi(q);                //4” -> 4
//                
//                //10进制转换为16进制
//                day=(day/10)*16+day%10;
//                        
//                
//                q=strtok(NULL,"-");            //week
//                
//                //字符串转换为整型
//                week = atoi(q);                //4” -> 4
//                
//                //10进制转换为16进制
//                week=(week/10)*16+week%10;
//        
//                set_date(year,month,day,week);
//                
//                //printf("%x,%x,%x\r\n",year,month,day);
            
//            }
            
            delay_ms(100);
            
//        }
    }

}


static volatile uint8_t  g_usart3_buf[128]={0};
static volatile uint32_t g_usart3_cnt=0;


void USART3_IRQHandler(void)
{
    
    OS_ERR err;
    
    uint8_t d;
    
    //进入中断
    OSIntEnter(); 
    
    //检测标志位
    if(USART_GetITStatus(USART3,USART_IT_RXNE) == SET)
    {
        
        //从串口3接收数据
        g_usart3_buf[g_usart3_cnt] = USART_ReceiveData(USART3);
        
        //记录多少个数据
        g_usart3_cnt++;
        
        //检测到'#'符或接收的数据满的时候则发送数据
        if(g_usart3_buf[g_usart3_cnt-1]=='#' || g_usart3_cnt>=(sizeof g_usart3_buf))
        {
            
            //发送消息队列
            OSQPost(&g_queue_usart3,(void *)g_usart3_buf,g_usart3_cnt,OS_OPT_POST_FIFO,&err);
            
            g_usart3_cnt=0;
            
        }
        

        //清空标志位
        USART_ClearITPendingBit(USART3,USART_IT_RXNE);
    }
    
    //退出中断
    OSIntExit();


希望各位工程师能指出错误