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.

代碼卡在SimplePeripheral_createTask

Part Number: CC2642R

各位好:

自从我新建立定時器跟任务

代码执行一次后,卡在SimplePeripheral_createTask

SDK:simplelink_cc13x2_26x2_sdk_5_20_00_52_for_CC6252r

static Clock_Struct ecgClock;
spClockEventData_t argecg =
{ .event = SP_ECG_EVT };


void SimplePeripheral_createTask(void)
{
  Task_Params taskParams;

  // Configure task
  Task_Params_init(&taskParams);
  taskParams.stack = spTaskStack;
  taskParams.stackSize = SP_TASK_STACK_SIZE;
  taskParams.priority = SP_TASK_PRIORITY;

  Task_construct(&spTask, SimplePeripheral_taskFxn, &taskParams, NULL);
}


static void SimplePeripheral_init(void)
{
.
.
.
    Util_constructClock(&ecgClock, SimplePeripheral_clockHandler, 1000, 0, true, (UArg)&argecg);
.
.
.
}


static void SimplePeripheral_clockHandler(UArg arg)
{
  spClockEventData_t *pData = (spClockEventData_t *)arg;

  if (pData->event == SP_PERIODIC_EVT)
  {
    // Start the next period
    Util_startClock(&clkPeriodic);

    // Post event to wake up the application
    SimplePeripheral_enqueueMsg(SP_PERIODIC_EVT, NULL);
  }
  else if (pData->event == SP_READ_RPA_EVT)
  {
    // Start the next period
    Util_startClock(&clkRpaRead);

    // Post event to read the current RPA
    SimplePeripheral_enqueueMsg(SP_READ_RPA_EVT, NULL);
  }
  else if (pData->event == SP_SEND_PARAM_UPDATE_EVT)
  {
    // Send message to app
    SimplePeripheral_enqueueMsg(SP_SEND_PARAM_UPDATE_EVT, pData);
  }
    else if( pData->event == SP_ECG_EVT)
  {
      SimplePeripheral_enqueueMsg(SP_ECG_EVT, NULL);
  }
}


static void ecg_Handler(void)
{
    ADC_Params_init(&params);
    adc = ADC_open(CONFIG_ADC_0, &params);

    if (adc == NULL) {
        Display_printf(displayHandle, 0, 0, "Error initializing CONFIG_ADC_0\n");
        while (1);
    }
    
    res = ADC_convert(adc, &adcValue0);
    
    if (res == ADC_STATUS_SUCCESS) {

        adcValue0MicroVolt = ADC_convertRawToMicroVolts(adc, adcValue0);
        Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 raw result: %d\n", adcValue0);
        Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 convert result: %d uV\n",adcValue0MicroVolt);
    }
    
    ADC_close(adc);
}
    

  • 您好我们已收到您的问题并升级到英文论坛寻求帮助,如有答复将尽快回复您。谢谢。

  • 您好,工程师这边目前没办法重现您的问题。

    代码在 SimplePeripheral_createTask 中就停止执行是吗? 代码无法执行到 SimplePeripheral_init是吗 ? 此外请问您是否已添加task?

    除此之外,请您验证下是否有其他任务使用 spTaskStack 的内容 (分配给 Simple_peripheral 任务的堆栈) ,并且堆栈正确对齐:

    // Task configuration
    Task_Struct spTask;
    #if defined __TI_COMPILER_VERSION__
    #pragma DATA_ALIGN(spTaskStack, 8)
    #else
    #pragma data_alignment=8
    #endif
    uint8_t spTaskStack[SP_TASK_STACK_SIZE];

  • 您好
    代码在SimplePeripheral_createTask 中就停止执行,代码无法执行到 SimplePeripheral_init
    无添加Task
    没有其他任务使用 spTaskStack 的内容

  • 好的感谢您确认的信息,已经跟进给工程师了哈。

  • 您好,这样的话有点奇怪,尚未创建的时钟应该不会影响任务的创建。 您试下,将您添加的所有代码一点一点的删除,然后看下您的project在哪一步能够正确创建task?

  • 您好,我将以下这段代码删除過後,project能正常运作

    static void ecg_Handler(void)
    {
        ADC_Params_init(&params);
        adc = ADC_open(CONFIG_ADC_0, &params);
    
        if (adc == NULL) {
            Display_printf(displayHandle, 0, 0, "Error initializing CONFIG_ADC_0\n");
            while (1);
        }
        
        res = ADC_convert(adc, &adcValue0);
        
        if (res == ADC_STATUS_SUCCESS) {
    
            adcValue0MicroVolt = ADC_convertRawToMicroVolts(adc, adcValue0);
            Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 raw result: %d\n", adcValue0);
            Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 convert result: %d uV\n",adcValue0MicroVolt);
        }
        
        ADC_close(adc);
    }

  • ok反馈给工程师了哈。

  • 您好,更新一下
    发现是ecg_Handler内的Display_printf导致整个代码卡住
    请问要怎么解决?

    另外,我想将adcValue0MicroVolt透过蓝芽传到手机
    请问有范例可以学习吗?

    Display_Handle displayHandle = NULL;
    #define FOOTER "UART Display testing........."
    
    static void SimplePeripheral_init(void)
    {
       Display_init();
       displayHandle = Display_open(Display_Type_UART, NULL);
       Display_printf(displayHandle, 0, 0, FOOTER);
       .
       .
       .
    }
    
    static void ecg_Handler(void)
    {
        ADC_Params_init(&params);
        adc = ADC_open(CONFIG_ADC_0, &params);
    
        if (adc == NULL) {
            Display_printf(displayHandle, 0, 0, "Error initializing CONFIG_ADC_0\n");
            while (1);
        }
    
        res = ADC_convert(adc, &adcValue0);
    
        if (res == ADC_STATUS_SUCCESS) {
    
            adcValue0MicroVolt = ADC_convertRawToMicroVolts(adc, adcValue0);
            Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 raw result: %d\n", adcValue0);
            Display_printf(displayHandle, 0, 0, "CONFIG_ADC_0 convert result: %d uV\n",adcValue0MicroVolt);
        }
    
        ADC_close(adc);
    }



  • 好的收到啦,反馈给工程师看下哈。

  • 您好,建议您在 Display_open 过程完成之前确保 Display_printf 过程没有被访问。 此外工程师会验证下 displayHandle 是否为 NULL。

    Simple_peripheral 示例展示了通过 GATT 表通过蓝牙进行数据传输,您可以参考下。也可以参阅我们的Simple Link Academy labs dedicated to this topic

  • 您好
    已经有添加验证 displayHandle 是否为 NULL
    在SimplePeripheral_init里面呼叫Display_prinitf有成功打印
    在其他地方呼叫Display_prinitf都没有打印

  • 好的收到哈,应该下个工作日给到您答复。

  • 在SimplePeripheral_init里面呼叫Display_prinitf有成功打印
    在其他地方呼叫Display_prinitf都没有打印

    您可以试下以下两个办法:

    1. 确保在task content中调用 Display_printf。

    2. Display_printf 可能会消耗大量堆栈,您可以看下是不是因为这个。详情请参阅debugging guide

  • 您好
    感谢您的帮忙
    最后发现是CLOCK的问题,当一次CLOCK结束后,要重新开启 Util_startClock蓝芽才会一直传送数值到手机上。