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.

TIRTOS使用內部計時器相關

Other Parts Discussed in Thread: CC3220SF

開發版CC3220SF,

CCS版本:Version: 8.2.0.00007 ,

OS:WINDOWS7 專業版,

使用的範例程式為timerled_CC3220SF_LAUNCHXL_tirtos_ccs,

現使用兩個GPT TIMER1與TIMER2進行燈號切換,

設定如下

GPT週期單位為Timer_PERIOD_US

GPT模式為Timer_CONTINUOUS_CALLBACK

GPT每100uS更新一次

抓出的波型如下

C2為GPT1

C4為GPT2

有幾個問題

Q1.依照範例程式的說明係使用TIRTOS,波形應該係GPT1與GPT2同時動作,怎會有GPT2落後GPT1近60幾uS?

Q2.若GPT1與GPT2要同時動作,需要怎麼設定或使用哪些方式?

以上煩請解或之!

謝謝

  • 例程有过修改吗?启动是否在同一线程?线程优先级的设置呢?
  • 你好

    因第一次接觸這一塊posix thread,有些沒很熟悉,請多指教

    程式如下

    #include <stddef.h>

    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/Timer.h>
    #include <ti/drivers/ADC.h>
    /* Board Header file */
    #include "Board.h"
    #include "pthread.h"

    void timer1Callback();
    void timer2Callback();

    void *mainThread(void *arg0)
    {
    /* Period and duty in microseconds */
    Timer_Handle timer1,timer2;
    Timer_Params params1,params2;
    int32_t status = 0;

    /* Call driver init functions */
    GPIO_init();
    Timer_init();

    /* Configure the LED pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    GPIO_setConfig(Board_GPIO_PIN_61, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    GPIO_setConfig(Board_GPIO_PIN_62, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    GPIO_setConfig(Board_GPIO_PIN_63, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* Turn off user LED */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
    GPIO_write(Board_GPIO_PIN_61, Board_GPIO_LED_OFF);
    GPIO_write(Board_GPIO_PIN_62, Board_GPIO_LED_OFF);
    GPIO_write(Board_GPIO_PIN_63, Board_GPIO_LED_OFF);

    /* Timer1 for adc, get data per 100uS
    */
    Timer_Params_init(&params1);
    params1.period = 100; // 100 uS,
    params1.periodUnits = Timer_PERIOD_US;
    params1.timerMode = Timer_CONTINUOUS_CALLBACK;
    params1.timerCallback = timer1Callback;
    timer1 = Timer_open(Board_TIMER1, &params1);

    if (timer1 == NULL) {
    /* Failed to initialized timer */
    while (1);
    }

    if (Timer_start(timer1) == Timer_STATUS_ERROR) {
    /* Failed to start timer */
    while (1);
    }

    /* Timer2 for accelerator, get data per 850uS
    */
    #define test_100u

    Timer_Params_init(&params2);
    #ifdef test_100u
    params2.period = 100;
    #else
    params2.period = 850; // 850 uS,
    #endif
    params2.periodUnits = Timer_PERIOD_US;
    params2.timerMode = Timer_CONTINUOUS_CALLBACK;
    params2.timerCallback = timer2Callback;

    timer2 = Timer_open(Board_TIMER2, &params2);

    if (timer2 == NULL) {
    /* Failed to initialized timer */
    while (1);
    }
    if (Timer_start(timer2) == Timer_STATUS_ERROR) {
    /* Failed to start timer */
    while (1);
    }
    return (NULL);
    }

    void timer1Callback()
    {
    GPIO_toggle(Board_GPIO_PIN_61);
    }

    void timer2Callback()
    {
    GPIO_toggle(Board_GPIO_PIN_62);
    }

    以上!