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.

CC1310: 无线发送数据后,影响其他功能的运行

Part Number: CC1310

上电启动后CPU GPIO和脉冲计数器功能可以正常工作;但是无线发送一条后GPIO功能不能驱动引脚,脉冲计数器(定时器)不能正常那个工作;

  • 但是无线发送一条后GPIO功能不能驱动引脚,脉冲计数器(定时器)不能正常那个工作;

    正常情况下无线发送不会影响其他部分,检查下是否存在引脚复用

  • 程序中只有一个线程,在启动后会过10秒后才会进行无线数据发送,发送之前数据采集是没有问题的,只要进行无线数据发送,引脚驱动和计数器就不能工作了,如果是引脚复用初始化之后程序运行之前应该就不能工作了,现在是刚开始可以。目前没有尝试其他功能,只用到了一个引脚写了一个传感器的驱动,还有一个计数器功能,这两个都会受到影响

  • 你的脉冲计数器是一直在计数吗,CPU同一时刻既在计数又在发送数据?

  • 不是,会在发送之前进行一定次数的计数,然后做一些处理后再发送,数据发送的的时候没有其他功能运行;

  • 那比较奇怪呀,将代码传上来看看

  • 两个计数器,计数之后发送出去,引脚驱动也是类似代码,指示计数器部分变成了引脚驱动读取传感器数据;代码如下

    void timerCallback_50ms(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) 
    {
    PIN_setOutputValue(POWT1PinHandle, CC1310_LAUNCHXL_PIN_POWT1, 0); 
    PIN_setOutputValue(POWT2PinHandle, CC1310_LAUNCHXL_PIN_POWT2, 0); 
    //GPTimerCC26XX_disableInterrupt(hTimer_50ms,GPT_MODE_ONESHOT_UP);
    GPTimerCC26XX_stop(hTimer_50ms);
    DataValueInit_Value.Temp1=GPTimerCC26XX_getValue(hTimer_count_1);
    DataValueInit_Value.Temp2=GPTimerCC26XX_getValue(hTimer_count_2);
    GPTimerCC26XX_clearValue(hTimer_count_1,0);
    GPTimerCC26XX_clearValue(hTimer_count_2,0);
    GPTimerCC26XX_stop(hTimer_count_1);
    GPTimerCC26XX_stop(hTimer_count_2);
    DataValueInit_Value.Temp_Flag=1;

    PIN_setConfig(T1PinHandle, PIN_BM_OUTPUT_MODE | PIN_BM_INPUT_MODE, CC1310_LAUNCHXL_PIN_T1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS|PIN_DRVSTR_MED);
    PIN_setConfig(T2PinHandle, PIN_BM_OUTPUT_MODE | PIN_BM_INPUT_MODE, CC1310_LAUNCHXL_PIN_T2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS|PIN_DRVSTR_MED); 
    }
    void Detect_Temperature(void)
    {
    PIN_setConfig(T1PinHandle, PIN_BM_OUTPUT_MODE | PIN_BM_INPUT_MODE, CC1310_LAUNCHXL_PIN_T1 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP);
    PIN_setConfig(T2PinHandle, PIN_BM_OUTPUT_MODE | PIN_BM_INPUT_MODE, CC1310_LAUNCHXL_PIN_T2 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP);

    PIN_setOutputValue(POWT1PinHandle, CC1310_LAUNCHXL_PIN_POWT1, 1);
    PIN_setOutputValue(POWT2PinHandle, CC1310_LAUNCHXL_PIN_POWT2, 1);
    GPTimerCC26XX_start(hTimer_50ms);
    GPTimerCC26XX_enableInterrupt(hTimer_50ms,GPT_MODE_ONESHOT_UP);
    GPTimerCC26XX_start(hTimer_count_1);
    //CT1820B_Temp_Conv();
    GPTimerCC26XX_start(hTimer_count_2); 
    } 
    void Result_Temperature(void)
    {

    DataValueInit_Value.Temp1_Value=Temp_Value(DataValueInit_Value.Temp1);
    DataValueInit_Value.Temp2_Value=Temp_Value(DataValueInit_Value.Temp2); 
    }
    void txFunctionUpdate(void)
    {
    uint16_t RealtimeVoltage=0;//,Temperature1=0,Temperature2=0;
    uint16_t BatteryState=0;
    /* Create packet with incrementing sequence number and random payload */
    BatteryState=(0x0001&scifTaskData.dataStream.state.batteryState)<<1;
    if((timeCount > 5)||abs(RealtimeVoltage - LastRealtimeVoltage) > DataValueInit_Value.BurstThreshold||Switchupdateflag==1)//定时和突变上传
    {
    timeCount=0;
    /* Call txFunction initialization */
    txFunctionInit();
    lbtPacket.payload[0] = (uint8_t)(DataValueInit_Value.seqNumber);
    lbtPacket.payload[1] = (uint8_t)(DataValueInit_Value.seqNumber>>8);
    lbtPacket.payload[2] = (uint8_t)(DataValueInit_Value.seqNumber>>16);
    lbtPacket.payload[3] = (uint8_t)(DataValueInit_Value.seqNumber>>24); 
    lbtPacket.payload[4] = (uint8_t)DataValueInit_Value.Temp1_Value;
    lbtPacket.payload[5] = (uint8_t)(DataValueInit_Value.Temp1_Value>>8);

    lbtPacket.payload[6] = (uint8_t)(SwitchState+BatteryState);
    lbtPacket.payload[7] = (uint8_t)(sendframecounter);
    lbtPacket.payload[8] = (uint8_t)(sendframecounter>>8); 
    sendframecounter++;
    if(sendframecounter%10==0)
    {
    SendframeUpdate(&sendframecounter);
    }
    lbtPacket.len = RFEASYLINKLBT_PAYLOAD_LENGTH;
    lbtPacket.dstAddr[0] = 0xF3;
    lbtPacket.absTime = 0;
    EasyLink_transmitCcaAsync(&lbtPacket, lbtDoneCb);

    }
    timeCount++;

    }


    while(1)
    {
    // Wait for an ALERT callback
    // Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);
    if(KeyMsg)
    {
    KeyMsg=0;
    Detect_Temperature();
    sleep(1);
    }
    if(DataValueInit_Value.Temp_Flag==1)
    {
    Result_Temperature();
    DataValueInit_Value.Temp_Flag=2;
    KeyMsg=1;
    }
    Key_ProcessUpdate();
    ADCInit();
    PIN_setOutputValue(RunPinHandle, CC1310_LAUNCHXL_PIN_RUNLED, (PIN_getOutputValue(CC1310_LAUNCHXL_PIN_RUNLED))?0:1); 
    Send_Flag++;
    if(Send_Flag==20)
    {
    Send_Flag=0;
    if(DataValueInit_Value.Temp_Flag==2)
    {
    txFunctionUpdate();
    }
    }
    }

  • 以后上传代码可以选择插入->代码进行插入,这样看起来会清楚一些

    大概看了下,当Send_Flag为20时,会进入发送无线数据,只有发完后才能继续执行其他的温度检测这些程序

    这可能是你说的影响其他程序的原因,你可debug单步运行查看具体的程序运行过程

  • 加了发送完成标志,发送完成之后再进行其他操作,但是程序就会死掉,不加的话程序不会死但是采集功能就不工作了

  • 我又改了一下,等发送完成之后再进行其他操作,还是会影响计数器工作。

  • 发送完成后具体是怎么影响的,运行到计数器依然不计数?

  • 是的,还是不计数