This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640中,新建任务的stackSize最大可以设为多少?

Other Parts Discussed in Thread: CC2640, LAUNCHXL-CC2640R2

目前使用simple_peripheral工程,并且添加PTM。然后还需要在simple_peripheral工程中新建一个任务。由于CC2640内存紧张,因此需要确认新建任务的stackSize最大可以设为多少。

我的步骤如下:
1、使用simple_peripheral工程,并且添加PTM。添加PTM的具体步骤参见帖子1和帖子2。链接见“7 附件”

2、验证添加的PTM可以正常运行之后,再新建一个任务COM_Task。任务的配置和创建如下:

#define COM_TASK_STACK_SIZE    512
#define COM_TASK_PRIORITY      5

void COM_Task_createTask(void)
{
    memset(&comTaskStack, 0xBB, sizeof(comTaskStack));

    /*----- Configure and create the COM task. -----*/
    Task_Params comTaskParams;
    Task_Params_init(&comTaskParams);
    comTaskParams.stack = comTaskStack;
    comTaskParams.stackSize = COM_TASK_STACK_SIZE;
    comTaskParams.priority = COM_TASK_PRIORITY;

    Task_construct(&comTaskStruct, COM_Task_Fxn, &comTaskParams, NULL);

}



int main()
{
  ...................

  ICall_init();
  ICall_createRemoteTasks(); /* Start tasks of external images - Priority 5 */

  /* Start task for NPI task */
  if( (PIN_getInputValue(CC2640R2_LAUNCHXL_SPI0_SRDY))==1 )//wrong
  {
      NPITask_createTask(ICALL_SERVICE_CLASS_BLE);
  }

  COM_Task_createTask(); 

  GAPRole_createTask();                            /* Kick off profile - Priority 3        */
  SimpleBLEPeripheral_createTask();                /* Priority 1                           */

  BIOS_start();                                    /* enable interrupts and start SYS/BIOS */

  return 0;
}

3、将pairMode 设置为 GAPBOND_PAIRING_MODE_INITIATE,以便于手机端可以直接弹出配对请求界面。如图1所示。


4、由于COM_TASK_STACK_SIZE 为 512,导致蓝牙配对工作不正常,在ios手机端无法弹出配对请求界面。经过分析发现,是因为COM_TASK_STACK_SIZE过大造成的。

5、simple_peripheral工程在添加PTM之后,还剩下多少内存空间?如何计算剩余的内存空间?COM_TASK_STACK_SIZE 最大值可以设置为多少?

6、附件
(1)SDK中的PTM的html文件的链接:
file:///C:/ti/simplelink_cc2640r2_sdk_1_40_00_45/docs/blestack/ble_user_guide/html/ble-stack-3.x/creating-a-custom-bluetooth-low-energy-application.html#using-production-test-mode-ptm

(2)simple_peripheral工程在我的电脑上的位置
C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\examples\rtos\CC2640R2_LAUNCHXL\blestack\simple_peripheral

(3)simplelink_cc2640r2_sdk_1_40_00_45 可从如下路径下载:

(4)CC2640R2 launchpad 可从这里购买:


(5)PTM的教学视频的链接:

(6)帖子1


(7)帖子2

7、我的开发环境
CCS:Code Composer Studio 7.2.0
SDK:simplelink_cc2640r2_sdk_1_40_00_45
hardware:CC26640R2 launchpad develop kit
VS: Microsoft Visual C++ 2010 Express
系统:win7 64 位