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.

CCS/LAUNCHXL-CC2640R2: Timer Problem in LaunchXL- CC2640R2

Part Number: LAUNCHXL-CC2640R2

Tool/software: Code Composer Studio

Hi,

I have been working on modification of ProjectZero on CC2640R2.

Just to know, The code has two services, first service has 38 characteristics and second service has 11 characteristics.

Everything is working well, until I added a GPIOTimer in my code.

Below is my code,

GPTimerCC26XX_Handle hTimer;//Global handle hTimer

//Timer functions declaration

void TimerInit();
void TimerStart();
void TimerStop();
void TimerCallback();

void ProjectZero_init(0{

.....

TimerInit();
TimerStart();

.....

}

/*****************************************************************************************/

void TimerInit(){

    GPTimerCC26XX_Params params;
    GPTimerCC26XX_Params_init(&params);
    params.width          = GPT_CONFIG_16BIT;
    params.mode           = GPT_MODE_PERIODIC_UP;
    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    hTimer = GPTimerCC26XX_open(CC2640R2_LAUNCHXL_GPTIMER3B, &params);
    if(hTimer == NULL) {
    UART_write(hUart, "\n\rFailed to open GPTimer", sizeof("\n\rFailed to open GPTimer"));
      //Task_exit();
    }
    else{
    UART_write(hUart, "\n\rGPTimer Initialized", sizeof("\n\rGPTimer Initialized"));
    }
    //Types_FreqHz  freq;
    xdc_runtime_Types_FreqHz freq;
    BIOS_getCpuFreq(&freq);
    GPTimerCC26XX_Value loadVal = freq.lo / 10 - 1; //47999
    GPTimerCC26XX_setLoadValue(hTimer, loadVal);
    GPTimerCC26XX_registerInterrupt(hTimer, TimerCallback, GPT_INT_TIMEOUT);
   // GPTimerCC26XX_start(hTimer);

}

/*****************************************************************************************/

void TimerStart(){
    GPTimerCC26XX_start(hTimer);
    UART_write(hUart, "\n\rTimer Started", sizeof("\n\rTimer Started"));
}

/*****************************************************************************************/

void TimerStop(){
    GPTimerCC26XX_stop(hTimer);
    UART_write(hUart, "\n\rTimer Stopped", sizeof("\n\rTimer Stopped"));
}

/*****************************************************************************************/

void TimerCallback(){
    static int count=0;
    count++;

    //
    //count is increment for every 10 milliseconds, and
    //made to zero when it reaches 10 count. Then it's one second.
    //

    if(count%10==0){
        count=0;
        UART_write(hUart, ".", sizeof("."));
    }

}

/*****************************************************************************************/

i can see the timer prints "." for every second and this shows that timer is running.

But when ever I try to connect to CC2640R2 using mobile app, it throws some over flow error.

I will share those logs below.

#000005 [ 0.227 ] INFO: (project_zero.c:1049) GAP is started. Our address: 0x546C0EA044D5
#000006 [ 0.227 ] INFO: (project_zero.c:1054) Advertising
......#000007 [ 6.441 ] INFO: (project_zero.c:1573) (CB) GAP State change: 6, Sending msg to app.
#000008 [ 6.441 ] INFO: (project_zero.c:1064) Connected. Peer address: 0x6E8AFF87EE07
#000009 [ 6.695 ] INFO: (project_zero.c:1360) HCI Command Complete Event received
.....#000010 [ 11.652 ] ERROR: (project_zero.c:1413) Flow control violated. Opcode of offending ATT msg: 0x10
.#000011 [ 12.965 ] INFO: (project_zero.c:1360) HCI Command Complete Event received
.#000012 [ 13.960 ] INFO: (project_zero.c:1573) (CB) GAP State change: 4, Sending msg to app.
#000013 [ 13.961 ] INFO: (project_zero.c:1573) (CB) GAP State change: 2, Sending msg to app.
#000014 [ 13.961 ] INFO: (project_zero.c:1073) Disconnected / Idle
#000015 [ 13.961 ] INFO: (project_zero.c:1054) Advertising

These are the logs, can anyone please tell me what is the issue or we can't use timer in project zero?

I have used the timer's CC2640R2_LAUNCHXL_GPTIMER3B, CC2640R2_LAUNCHXL_GPTIMER2A and CC2640R2_LAUNCHXL_GPTIMER1A.

Everything results the same.

Thanks

JanSom

  • Which SDK version is your modified ProjectZero based on?
  • Hi Jan,

    Could you elaborate on how you plan to use the timer, it seems you are simply trying to setup a "second" timer, is that the case?

    How are you accessing the UART in this case? I expect the UART port to be already used by the Display driver.
    Assuming no actual collision here (if you have solved Display UART + UART driver scenario), what "mode" are you operating UART in (blocking or callback)?
  • Hi Edward.P and M-W,

    Sorry for late response to you both.

    To Edward.P, I am using SDK version simplelink_cc2640r2_sdk_2_30_00_28.

    To M-W, I am not using Display UART, I am using UART logs. Its on default mode, which is blocking mode.

    I resolved my issue, it was with too much unused global variables and functions.

    I cleared that and it resolved my issue. Thank you both for your support .