微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > CC2640R2F从机(Peripheral)执行GATT_WriteNoRsp后程序崩溃问题

CC2640R2F从机(Peripheral)执行GATT_WriteNoRsp后程序崩溃问题

时间:10-02 整理:3721RD 点击:

CC2640R2F参考官方simple_peripheral_cc2640r2lp_app例程写了一段Peripheral向Central写变量的代码,采用WriteNoRsp方式,connection handle和character handle已事先正确获得,并且simple_peripheral_cc2640r2lp_stack部分已去掉了NO_GATT_CLIENT定义,WriteNoRsp返回SUCCESS,通过sniffer抓包也能够抓到Peripheral发送的写变量数据包。

现在遇到的问题是WriteNoRsp执行完之后,执行到Event_post这里程序就会崩溃,跳到ti_sysbios_family_arm_m3_Hwi_excHandler,如果不执行WrtieNoRsp就没有问题,查了很久都没有找到原因,希望各位高手能指点一二,非常感谢!

static gattMsg_t t_Message;

static uint16 u16_ConnectionHandle;

static uint16 u16_CharacterHandle;

static ICall_SyncHandle t_ICallSyncHandle;

static ICall_EntityID t_ICallEntityID;

#define EVENT_WRITE (1 << 0)


void ProcessTask(UArg a0, UArg a1)
{
uint32_t t_Events;


ICall_registerApp(&t_ICallEntityID, &t_ICallSyncHandle);


while (1)
{
    t_Events = Event_pend(t_ICallSyncHandle, Event_Id_NONE,
    EVENT_WRITE, ICALL_TIMEOUT_FOREVER);

    //do something

}
}


uint GATT_Write (const uint8 *u8p_Data, uint8 u8_Length)
{
    attWriteReq_t *tp_WriteRequest;

    tp_WriteRequest = &t_Message.writeReq;

    tp_WriteRequest->pValue = (uint8 *)GATT_bm_alloc(u16_ConnectionHandle, ATT_WRITE_REQ, (uint16)u8_Length, NULL);

    if (tp_WriteRequest->pValue != NULL )
    {
       tp_WriteRequest->len = u8_Length;
       tp_WriteRequest->sig = 0;
       tp_WriteRequest->cmd = 1;
       memcpy(tp_WriteRequest->pValue, u8p_Data, u8_Length);
       tp_WriteRequest->handle = u16_CharacterHandle;

       if (GATT_WriteNoRsp(u16_ConnectionHandle, tp_WriteRequest) != SUCCESS)
       {
            GATT_bm_free(&t_Message, ATT_WRITE_REQ);
            return FUNCTION_FAIL;
       }
   }

   Event_post(t_ICallSyncHandle, EVENT_WRITE);

   return FUNCTION_OK;

}

找到原因了,Gatt_WriteNoRsp所在任务堆栈溢出了,原来参考官方示例设置为512字节,改成1024字节就正常了,官方示例的堆栈设置太保守了...

看到你在E2E发的帖子了,原因是堆栈溢出。其实对于堆栈大小,TI没有明确规定,一般来说,如果应用比较复杂, 需要手动改一下大小

谢谢分享经验,说明rtos还是耗费硬件资源的

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top