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: Insert Code/Tasks in projectzero - BLE that are not related to BLE - functions

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640,

Hi,

I've developed a custom board with the CC2640 and adapted the BLE projectZero and ran it on my device. So far I can connect and switch on the LEDs via BLE Scanner.
I read the labs and the user guide and as far as I understood for each BLE - service that I want to impIement I can follow the instructions in the lab and projectzero is an example of how this is done.
I found the for(;;) main loop in projectzero.c, but it is not clear to me where I can write code for tasks that are not related to BLE. 
For example I want to read a voltage with the ADC and then dim a LED via a PWM/Potentiometer in the "background". So while being able to send data over BLE, parallel I want to dim the LED with a Poti. 
This task already works without the context of the BLE Stack, but where would I insert this code in projectzero, so this task is functioning without interefering with the BLE-functions?

Thank you and best regards, Alex

  • I suppose you can create a new task and do it in the task.
  • Hello Alexander,

    You can see an example of adding a task with the "Bluetooth Low Energy + Sensors BoosterPack" SimpleLink Academy lab for CC2640R2F on dev.ti.com/tirex. Current link: dev.ti.com/.../

    I suggest going through this and TI-RTOS labs for further examples of performing sensor operations with the BLE Stack.

    Best wishes
  • Hi JXS,

    thank you for your reply. The hint with the BLE + Sensors BoostPack lab really helped, I did all the others, but somehow missed out on this one. 
    I managed now to add a service and a task. Instead of reading a temperature I'm reading an ADC-Value, lighting up a LED over a certain threshold.

    while (1) {
    // Event_pend(readEvent, Event_Id_NONE, Event_Id_00, BIOS_WAIT_FOREVER);

    res = ADC_convert(adc, &adcValue);
    if (res == ADC_STATUS_SUCCESS) {
    //Display_printf(displayHandle, 1, 0, "ADC Reading %d", adcValue);

    if (adcValue >= 1500){
    GPIO_write(Board_GPIO_Lade, 0);

    } else{
    GPIO_write(Board_GPIO_Lade, 1);

    }
    }
    Task_sleep(100 * (1000 / Clock_tickPeriod));

    //Poti1_SetParameter( POTI1_POTIDATA, TEMP_DATA_SIZE, &Value ); //Replace MYTEMP_MYTEMPDATA with your service & characteristic name if different
    }



    If I comment out the functions:

    Event_pend(readEvent, Event_Id_NONE, Event_Id_00, BIOS_WAIT_FOREVER);

    Poti1_SetParameter( POTI1_POTIDATA, TEMP_DATA_SIZE, &Value );

    I expected to be able to light up the LED depending on a Poti-Position that I connected to the ADC-pin, WHILE (concurrently) I can send and receive messages via BLE-Scanner (e.g. light up LED or read Button as it is done in projectzero, which I'm using as a starting point).
    What actually happens is that the program stucks in the while(1) - loop, but I assumed it will be interrupted by HWIs from the BLE - Stack. Adding task_sleep() offers enough time to somehow work pseudo-concurrently, but that's not what I want.

    So my question is, what do I need to insert in the function, in order to properly cooperate with the BLE - Stack?

    Thank you very much, your support is highly appreciated! Alex

  • Ok, I changed the priority of the projectZero - Task to a higher one than my custom - Task and it works nicely. I mistook priority 1 to be the highest instead of the lowest.
    This resolved my issue. Thank you very much TexasInstruments, it's a pleasure to work with your products!