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; }
Jianfeng Lv:
找到原因了,Gatt_WriteNoRsp所在任务堆栈溢出了,原来参考官方示例设置为512字节,改成1024字节就正常了,官方示例的堆栈设置太保守了…
Viki Shi:
看到你在E2E发的帖子了,原因是堆栈溢出。其实对于堆栈大小,TI没有明确规定,一般来说,如果应用比较复杂, 需要手动改一下大小
da qin zheng sheng:
谢谢分享经验,说明rtos还是耗费硬件资源的
user4941551:
回复 Jianfeng Lv:
请问一下这个堆栈大小在哪里更改的
huijun li:
回复 Jianfeng Lv:
高手您好:请问一下这个堆栈大小在哪里更改的啊