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.

CC2640R2F蓝牙数据发送

Expert 2270 points
Other Parts Discussed in Thread: CC2640R2F

CC2640R2F使用两个设备, 主机和从机通信, 从机采集数据100ms向主机发送数据, 主机再将数据通过串口输出, 从机返回的数据间隔最大达到了300ms左右, 这种情况下有3条数据返回的时间几乎一样, 这种情况怎么解决?

下面时蓝牙连接参数

// Minimum connection interval (units of 1.25ms, 8=10ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 40


// Maximum connection interval (units of 1.25ms, 8=10ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 56

// Slave latency to use if automatic parameter update request is enabled
#define DEFAULT_DESIRED_SLAVE_LATENCY 0

// Supervision timeout value (units of 10ms, 1000=10s) if automatic parameter
// update request is enabled
#define DEFAULT_DESIRED_CONN_TIMEOUT 300 

// Whether to enable automatic parameter update request when a connection is
// formed
#define DEFAULT_ENABLE_UPDATE_REQUEST GAPROLE_LINK_PARAM_UPDATE_WAIT_REMOTE_PARAMS

// Connection Pause Peripheral time value (in seconds)
#define DEFAULT_CONN_PAUSE_PERIPHERAL 6

  • “从机返回的数据间隔最大达到了300ms左右, 这种情况下有3条数据返回的时间几乎一样” 没看懂,是不是从机发送的数据间隔最大达到了300ms左右, 这种情况下有3条数据返回的时间几乎一样?

  • 主机通过串口发送到电脑, 下面是数据EVxxx[时间格式: 时:分:秒.毫秒]
    1: EV309[10:22:10.740]
    2: EV1425[10:22:10.840]
    3: EV364[10:22:10.939]
    4: EV305[10:22:11.039]
    5: EV301[10:22:11.340]
    6: EV303[10:22:11.341]
    7: EV305[10:22:11.342]
    8: EV298[10:22:11.439]
    9: EV308[10:22:11.539]
    10: EV310[10:22:11.640]
    11: EV334[10:22:11.743]
    第4条数据和第5条数据差了300ms
    第5条数据和第6条数据差了1ms
    第6条数据和第7条数据差了1ms
    其它的差不多是100ms左右,


    为什么从机返回的数据不是在时间间隔100ms左右?

  • 这里面经过多种传输技术,返回数据的时间不是完全跟设置一致的,变数太多了。你设置的发送时间,100ms一次,只能决定发送频率,不能决定返回频率
  • 从机设置了蓝牙发送数据, 蓝牙不会立即将数据返回吗
  • 主机只有这一个任务,没有其他任务占用吗
  • 主机有一个任务
  • 串口不就是另一个任务?
  • 串口是用事件的发送的

    int main()
    {
    #if defined( USE_FPGA )
    HWREG(PRCM_BASE + PRCM_O_PDCTL0) &= ~PRCM_PDCTL0_RFC_ON;
    HWREG(PRCM_BASE + PRCM_O_PDCTL1) &= ~PRCM_PDCTL1_RFC_ON;
    #endif // USE_FPGA

    /* Register Application callback to trap asserts raised in the Stack */
    RegisterAssertCback(AssertHandler);
    Power_init();
    // PIN_init(BoardGpioInitTable);
    if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
    /* Error with PIN_init */
    while (1);
    }


    #if defined( USE_FPGA )
    // set RFC mode to support BLE
    // Note: This must be done before the RF Core is released from reset!
    SET_RFC_BLE_MODE(RFC_MODE_BLE);
    #endif // USE_FPGA

    // Enable iCache prefetching
    VIMSConfigure(VIMS_BASE, TRUE, TRUE);

    // Enable cache
    VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);

    #if !defined( POWER_SAVING ) || defined( USE_FPGA )
    /* Set constraints for Standby, powerdown and idle mode */
    // PowerCC26XX_SB_DISALLOW may be redundant
    Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW);
    #endif // POWER_SAVING | USE_FPGA
    Power_setDependency(PowerCC26XX_XOSC_HF);
    #ifdef ICALL_JT
    user0Cfg.appServiceInfo->timerTickPeriod = Clock_tickPeriod;
    user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs();
    #endif /* ICALL_JT */
    /* Initialize ICall module */
    ICall_init();

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

    /* Kick off profile - Priority 3 */
    GAPCentralRole_createTask();

    /* Kick off application - Priority 1 */
    SimpleCentral_createTask();

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

    return 0;
    }

  • 串口事件发送也是主机去处理的,BLE跟串口是不冲突,但是都需要CPU核去处理,这里可能存在时间差