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: Program halt when using GGS_SetParameter function

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

Hi Sir / Madam,

I am developing using CC2640R2F.

My program halt when applying GGS_setParameter function.

When I trace the following flow :

(1)     GGS_SetParameter(GGS_DEVICE_NAME_ATT, len, name);               then ,

(2)     profileSetParameter(param, len, value, DISPATCH_GAP_GATT_SERV,  DISPATCH_PROFILE_SET_PARAM, matchGGSSetParamCS);         then,

(3)     sendWaitMatchCS(ICall_getEntityId(), msg, matchCSFn);             then,

(4)     errno = ICall_sendServiceMsg(src, ICALL_SERVICE_CLASS_BLE,  ICALL_MSG_FORMAT_3RD_CHAR_TASK_ID, msg);               then,

(5)     ICall_send(src, dstentity, format, msg);                 then,

(6)     ICall_MsgHdr *hdr = (ICall_MsgHdr *) msg - 1;         then,   --------->  the trace suddenly missing and

program halt as shown in the following disassembly display:

0x37f8: 0xbeab      BKPT     #0xab

I am developing from Simple_Peripheral, and would like to do connectable advertising with customise advertising data.

Please help.

Cheers,

KF

  • Hi,

    Can you provide more information? What other modification have you done to the project?

    In our out of box example, the function you want to use is already in place.
    // Set the GAP Characteristics
    GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
  • Hi Christin,

    I am developing BLE application named fbBri from simple_peripheral project.

    My problem is : -----> My program halt, when I pull out a statement from static void simpleperipheralBLEPeripheral_init(void), to process it elsewhere.

    The error is show in disassembly code :
    0x37f8: 0xbeab BKPT -------> the program stops here.

    The statement I pull out (inside function static void simpleperipheralBLEPeripheral_init(void) ) is :
    // Setup the GAP
    GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);

    I process this statement inside file GapProfileApp.c, a file I created, located inside : fbBri_kf\fbBri\src\app , The function (void GapProfileApp__Init(void)) is just simple :

    void GapProfileApp__Init(void)
    {
    /* Setup the GAP */
    GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
    return;
    }

    Other flow is same as default. I have run it and then, the program halt.


    Let me explain my files structure and problem :
    In the simple_peripheral.c file : static void simpleperipheralBLEPeripheral_init(void),
    I have taken out a statement : GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
    and put it inside a function named : void GapProfileApp__Init(void).


    void GapProfileApp__Init(void), is a function I created myself, inside a file named GapProfleApp.c .

    I am using IAR IDE, all the codes (Stack and App) "Rebuild All" successfully.

    My file structure is as follows:

    In my whole project folder :
    ---> I have (1) my project (fbBri), (2) simplelink_cc2640r2_sdk_1_00_00_22 and (3) xdctools_3_32_01_22_core.

    I have move my project (fbBri) from the same level as simpleperipheral at simplelink_cc2640r2_sdk_1_00_00_22\examples\rtos\CC2640R2_LAUNCHXL\blestack , to outside simplelink_cc2640r2_sdk_1_00_00_22. I have configure all the paths to be correct and compile successfully.
    Inside my project (fbBri), the structure is the same as simpleperipheral .
    The only difference is that I have add some user codes for the feature of my product, into a folder named "Profiles", inside my project (fbBri) folder. Which is same level as "src" and "tirtos"

    I have also try :
    void simpleperipheralBLEPeripheral_init(void), which is without static, and then extern void simpleperipheralBLEPeripheral_init(void) in .h file. It fails the same error message.


    Please help.


    Thank you very much.

    Cheers,
    KF
  • Hi Christin,

    I am troubleshooting the same problem:

    Inside my function GapProfileApp__Init(); is the following:

    void GapProfileApp__Init(void)
    {
    /* Setup the GAP */
    GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
    return;
    }

    My debug is as follows :


    (1) I have put GapProfileApp__Init(); inside int main() , between GAPRole_createTask(); and fbBriBLEPeripheral_createTask();
    , It is not causing program halt.


    (2) Then, I have put GapProfileApp__Init(); inside void fbBriBLEPeripheral_createTask(void),
    before statement : Task_construct(&sbpTask, FoboBridgeBLEPeripheral_taskFxn, &taskParams, NULL); ,
    , It is not causing program halt.


    (3) Then, I have put GapProfileApp__Init(); inside static void fbBriBLEPeripheral_taskFxn(UArg a0, UArg a1), before statement: fbBriBLEPeripheral_init(); , , It is not causing program halt.


    (3) Then have put GapProfileApp__Init(); inside void fbBriBLEPeripheral_init(void), as the first statement, which is before ICall_registerApp(&selfEntity, &syncEvent); , It is not causing program halt.

    (4) But when I put it after ICall_registerApp(&selfEntity, &syncEvent); , program halt after execute GapProfileApp__Init(); statement.


    May I have your advice please ? May I know the root cause ?




    Thank you very much.

    Cheers,
    KF
  • Hi,

    I am still not following. Since you started with simple_peripheral and the following has been used in the SimpleBLEPeripheral_init
    // Setup the GAP
    GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);

    Can you try not doing any modification(exception re-constructure the file location) to the project and just build and run, see if it's functioning. If it's running as expected, then take it from there.

    The problem you are seeing does not make too much sense to me as those functions you have troubling using are already part of our out of box example.
  • Thanks Christin. I will troubleshoot from here, according to your suggestion.

    Cheers,
    KF
  • Hi F Chng,

    For most part of your problem, take TI Christin advice. To get some understanding read the "CC2640 and CC2650 SimpleLink™Bluetooth® low energy Software Stack 2.2.1 Developer's Guide"

    F Chng said:
    I have move my project (fbBri) from the same level as simpleperipheral at simplelink_cc2640r2_sdk_1_00_00_22\examples\rtos\CC2640R2_LAUNCHXL\blestack , to outside simplelink_cc2640r2_sdk_1_00_00_22.

    I have advised you not to do this. This is what I did below. I added the sensortag folder to same level with simple_peripheral.

    Christin, I work with F Chng.

    - kel

  • Hi Christin,

    Many thanks for your suggestion. I follow your developing method. Restart all from recommended location. Step by step and level by level. Pull out until to my desired location. Finally, I am able to make it work. Successfully execute inside the scope of my project requirement. However, the root cause of previous failure is still unknown. Because I redo everything. Anyway, It works finally. Many thanks.

    But, I receive a weird message each time I click on start debug :
    Two dialog boxes entitle "Get Alternative File" appear.

    Both with messages :

    Could not find the following source file:
    C:\Jenkins\Jobs\FWGroup-DriverLib\workspace\modules\output\cc26xx_ch2_1_0_ext\driverlib\chipinfo.c

    Could not find the following source file:
    C:\Jenkins\Jobs\FWGroup-DriverLib\workspace\modules\output\cc26xx_ch2_1_0_ext\driverlib\chipinfo.h

    Both dialog box have soft button "Skip".

    After click on this, program execute as normal.

    May I know what does this message means ? I search my C drive. It does not have a anything named "Jenkins".
    Will this message affect the operation of my program ?

    Besides, I have search the file chipinfo.c and chipinfo.h. It is located inside :
    simplelink_cc2640r2_sdk_1_00_00_22\source\ti\devices\cc26x0r2\driverlib .
    This file is about the hardware revision, waferID ,....., etc. Will it affect my program If I choose "do not prompt me this message again" ?

    I am using IAR. May I know how I can direct IAR to search for this file every time It start debug ? So that, I will not be prompt this message again.

    Thank you very much.

    Please advice.


    Cheers,
    KF
  • Hi Christin,

    A couple of thanks again. This problem also solved.
    Don't know why IAR will not search for the right directory for this file.
    But after I add chipinfo.c under startup folder, it will not pop up.

    Thank you.

    Cheers,
    KF
  • Hi Christin,

    A couple of thanks again. This problem also solved.
    Don't know why IAR will not search for the right directory for this file.
    But after I add chipinfo.c under startup folder, it will not pop up.

    Thank you.

    Cheers,
    KF
  • Hi Christin,

    I am attaching Buzzer in to CC2640R2 Launchpad. I use PWM to drive one of the input of the buzzer.
    Currently I am developing this PWM in CC640R2. I use the ready example (pwmled.c) inside :
    D:\Project\Bridge\Bridge_kfchoong\simplelink_cc2640r2_sdk_1_00_00_22\examples\rtos\CC2640R2_LAUNCHXL\drivers\pwmled

    I rename the void *mainThread(void *arg0) as pwminit(). the for temporary I slot it inside location as shown :

    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);

    PIN_init(BoardGpioInitTable);


    pwmInit();

    .
    .
    .
    .
    .

    Compile successful. I am now facing a problem when executing it.

    The two led (red and green) turn off when executing
    handle = handle->fxnTablePtr->openFxn(handle, params);

    inside PWM_Handle PWM_open(uint_least8_t index, PWM_Params *params) . which is then inside pwminit().


    I check other parameters, they are normal logically.


    May I have your advice ?
    May I know how should I troubleshoot from here ?


    Thank you very much.

    Cheers,
    KF
  • There is also no Led blinking (suppose to blink) when I run the complete program.

    Thank you.

    Please advice soon.
    Cheers,
    KF
  • Where did you call PWM open and start? You should wait till BIOS_START is call and add those call in your custom application_init
  • Hi Christin,


    I called it just after PIN_init(BoardGpioInitTable);, before the BIOS_start(); , shown in the following :

    int main()
    {
    uint8_t debug11;


    #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);

    PIN_init(BoardGpioInitTable);

    pwmInit(); --------------------------------> here ....,,,,,,


    #ifdef CC1350_LAUNCHXL
    // Enable 2.4GHz Radio
    radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);

    #ifdef POWER_SAVING
    Power_registerNotify(&rFSwitchPowerNotifyObj, PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY, (Power_NotifyFxn) rFSwitchNotifyCb, NULL);
    #endif //POWER_SAVING
    #endif //CC1350_LAUNCHXL

    #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

    #ifdef ICALL_JT
    /* Update User Configuration of the stack */
    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 */
    GAPRole_createTask();

    BridgeBLEPeripheral__CreateTask();

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

    return 0;
    }



    I put it there just to see how it work before I put it inside my code.

    Would you please advice how to put it inside my code ?
    I am not familiar with Ti RTOS yet. I only kwno in brief that ti need to create a task and then,..., I am still blur.

    Please advice.


    Thank you very much.

    Cheers,
    KF
  • Please take a look at the documentation(TI-RTOS Kernel User’s Guide) comes with TI-RTOS and we do have simplelink_academy training covering TI-RTOS basic(software-dl.ti.com/.../overview.html)
  • Hi Christin,

    Many thanks for your advice.

    Due to I am rushing for due date, before I proceed study TI RTOS, may I ask some pre study question.

    I take sensortag project ( D:\ti\simplelink\ble_sdk_2_02_01_18\src\examples\sensortag ) as an example.

    In its main:

    int main()
    {
    /* Register Application callback to trap asserts raised in the Stack */
    RegisterAssertCback(AssertHandler);

    PIN_init(BoardGpioInitTable);

    #ifdef CC1350_LAUNCHXL
    // Enable 2.4GHz Radio
    radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);

    #ifdef POWER_SAVING
    Power_registerNotify(&rFSwitchPowerNotifyObj,
    PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY,
    (Power_NotifyFxn) rFSwitchNotifyCb, NULL);
    #endif //POWER_SAVING
    #endif //CC1350_LAUNCHXL

    #ifndef POWER_SAVING
    /* Set constraints for Standby and Idle mode */
    Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW);
    #endif // POWER_SAVING

    /* Initialize ICall module */
    ICall_init();

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

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

    /* Kick off application - Priority 1 */
    SensorTag_createTask();
    SensorTagTmp_createTask();
    SensorTagHum_createTask();
    SensorTagBar_createTask();

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

    return 0;
    }


    From my understanding, -------------------------------------------------------------------------------------------

    We create all task before BIOS_start(); . Inside SensorTag_createTask(); , has statement :
    Task_construct(&sensorTagTask, SensorTag_taskFxn, &taskParams, NULL); , which is then go to an endless loop inside function :
    static void SensorTag_taskFxn(UArg a0, UArg a1). Inside SensorTag_taskFxn, has an endless Application main loop :
    for (;;) , which is act like a polling system. This for(;;) is very similar as while(1);
    All these functions is inside sensortag_lp.c , which also include all other functions inside.

    Unfortunately, inside SensorTagTmp_createTask(); , SensorTagHum_createTask(); and SensorTagBar_createTask(); is empty. If I want to make these 3 create task work as SensorTag_createTask(); , should I also need to create 3 files namely :
    SensorTagTmp.c, SensorTagHum.c and SensorTagBar.c files, which content is very similar to sensortag_lp.c ? In these 3 .c files, it will have its own important functions like :
    Task_construct(&SensorTagTmpTask, SensorTagTmp_taskFxn, &taskParams, NULL);
    static void SensorTagTmp_taskFxn(UArg a0, UArg a1)

    Task_construct(&SensorTagHumTask, SensorTagHum_taskFxn, &taskParams, NULL);
    static void SensorTagHum_taskFxn(UArg a0, UArg a1)

    Task_construct(& SensorTagBarTask, SensorTagBar_taskFxn, &taskParams, NULL);
    static void SensorTagBar_taskFxn(UArg a0, UArg a1)

    Finally, all event from BIOS_Start wil be capture inside the for(;;) loop. Am I correct ?



    Thank you very much.

    Please advice soon.


    Cheers,
    KF
  • Hi Christin,

    I have add my PwmLed_Init() inside BridgeBLEPeripheral__Init().

    PwmLed_Init() :
    void PwmLed_Init (PWM_Params params, PWM_Handle pwm1, PWM_Handle pwm2, uint16_t pwmPeriod)
    {
    /* Call driver init functions. */
    PWM_init();
    PWM_Params_init(&params);
    params.dutyUnits = PWM_DUTY_US;
    params.dutyValue = 0;
    params.periodUnits = PWM_PERIOD_US;
    params.periodValue = pwmPeriod;
    pwm1 = PWM_open(Board_PWM0, &params);
    if (pwm1 == NULL) {
    /* Board_PWM0 did not open */
    while (1);
    }
    PWM_start(pwm1);
    if (Board_PWM1 != Board_PWM0)
    {
    pwm2 = PWM_open(Board_PWM1, &params);
    if (pwm2 == NULL) {
    /* Board_PWM0 did not open */
    while (1);
    }
    PWM_start(pwm2);
    }
    return;
    }

    Then, inside BridgeBLEPeripheral__Init():
    static void BridgeBLEPeripheral__Init(void)
    {
    // ******************************************************************
    // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
    // ******************************************************************
    // Register the current thread as an ICall dispatcher application
    // so that the application can send and receive messages.
    ICall_registerApp(&selfEntity, &syncEvent);

    /* [kf] Insert PwmLed_Init () here for testing only. */
    PwmLed_Init(params, pwm1, pwm2, pwmPeriod); -----> added here .....

    #ifdef USE_RCOSC
    RCOSC_enableCalibration();
    #endif // USE_RCOSC

    Then, inside static void BridgeBLEPeripheral__TaskFxn(UArg a0, UArg a1) :
    static void BridgeBLEPeripheral__TaskFxn(UArg a0, UArg a1)
    {
    /* [kf] Refer to CC26...SimpleLink BLE ... Developer's Guide.pdf, Pg. 66,
    Figure 4-3. SBP Task Flow Chart. */

    // Initialize application
    BridgeBLEPeripheral__Init(); -----------> init here. inside has pwmled_init.

    // Application main loop
    for (;;)
    {
    uint32_t events;

    // Waits for an event to be posted associated with the calling thread.
    // Note that an event associated with a thread is posted when a
    // message is queued to the message receive queue of the thread
    events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS, ICALL_TIMEOUT_FOREVER);

    if (events)
    {
    ICall_EntityID dest;
    ICall_ServiceEnum src;
    ICall_HciExtEvt *pMsg = NULL;

    if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS)
    {
    uint8 safeToDealloc = TRUE;

    if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))
    {
    ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;

    // Check for BLE stack events first
    /* [kf] refer CC2640 & CC2650 SimpleLink BLE Softw Stack 2.2.1 Developer's Guide.pdf
    pEvt->signature=0xFFFF if event is from BLE protocol stack. */
    if (pEvt->signature == 0xffff)
    {
    if (pEvt->event_flag & SBP_HCI_CONN_EVT_END_EVT)
    {
    // Try to retransmit pending ATT Response (if any)
    BridgeBLEPeripheral__SendAttRsp();
    }
    }
    else
    {
    // Process inter-task message
    safeToDealloc = BridgeBLEPeripheral__ProcessStackMsg((ICall_Hdr *)pMsg);
    }
    }

    if (pMsg && safeToDealloc)
    {
    ICall_freeMsg(pMsg);
    }
    } //close if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS)


    // If RTOS queue is not empty, process app message.
    if (events & SBP_QUEUE_EVT)
    {
    /* [kf] Perform pwmled application task. */
    PwmLed_On(pwm1, pwm2, duty, dutyInc, time, pwmPeriod);

    while (!Queue_empty(appMsgQueue))
    {
    sbpEvt_t *pMsg = (sbpEvt_t *)Util_dequeueMsg(appMsgQueue);
    if (pMsg)
    {
    // Process message.
    BridgeBLEPeripheral__ProcessAppMsg(pMsg);

    // Free the space from the message.
    ICall_free(pMsg);
    }
    }
    }


    if (events & SBP_PERIODIC_EVT)
    {
    Util_startClock(&periodicClock);

    // Perform periodic application task
    BridgeBLEPeripheral__PerformPeriodicTask();
    }

    /* [kf] Added this event to handle pwmled */
    if (events & SBP_PWMLED_EVT)
    {
    /* [kf] Perform pwmled application task. */
    PwmLed_On(pwm1, pwm2, duty, dutyInc, time, pwmPeriod); ------------> Added PwmLed_On here.......
    }


    #ifdef FEATURE_OAD
    if (events & SBP_QUEUE_PING_EVT)
    {
    while (!Queue_empty(hOadQ))
    {
    oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);

    // Identify new image.
    if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ)
    {
    OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
    }
    // Write a next block request.
    else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ)
    {
    OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
    }

    // Free buffer.
    ICall_free(oadWriteEvt);
    }
    }
    #endif //FEATURE_OAD

    } //close if (events)

    }//close for (;;)

    }



    I expect after runing this pwmled_On the loght will blink once, for Pwmled_On is :
    void PwmLed_On(PWM_Handle pwm1, PWM_Handle pwm2, uint16_t duty, uint16_t dutyInc, uint32_t time, uint16_t pwmPeriod)
    {
    /* Loop forever incrementing the PWM duty */
    //while (1) { /* [kf} Commented out bercause taken over by TIRTOS Loop. */
    PWM_setDuty(pwm1, duty);

    if (pwm2)
    {
    PWM_setDuty(pwm2, duty);
    }

    duty = (duty + dutyInc);

    if (duty == pwmPeriod || (!duty))
    {
    dutyInc = - dutyInc;
    }

    //usleep(time); /* [kf] temporary commented out becasue compile fail */
    //}

    return;
    }


    In my main forsgram, main() is :
    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);

    PIN_init(BoardGpioInitTable);

    #ifdef CC1350_LAUNCHXL
    // Enable 2.4GHz Radio
    radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);

    #ifdef POWER_SAVING
    Power_registerNotify(&rFSwitchPowerNotifyObj, PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY, (Power_NotifyFxn) rFSwitchNotifyCb, NULL);
    #endif //POWER_SAVING
    #endif //CC1350_LAUNCHXL

    #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

    #ifdef ICALL_JT
    /* Update User Configuration of the stack */
    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 */
    GAPRole_createTask();

    BridgeBLEPeripheral__CreateTask(); --------------------------> task is construct here.

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

    return 0;
    }



    However, my LED is not blink. It is off.
    I have set the led to be high by default. But whenever prog executed the second handler, LED is off,
    as shown in the following:

    PWM_Handle PWM_open(uint_least8_t index, PWM_Params *params)
    {
    PWM_Handle handle = NULL;

    if (isInitialized && (index < PWM_count)) {
    /* If params are NULL use defaults */
    if (params == NULL) {
    params = (PWM_Params *) &PWM_defaultParams;
    }

    /* Get handle for this driver instance */
    handle = (PWM_Handle) &(PWM_config[index]);

    handle = handle->fxnTablePtr->openFxn(handle, params); ---------------> Led off when after this statement.
    }

    return (handle);
    }



    Please advice.
    Thank you very much.



    Cheers,
    KF
  • Hi,

    It's pretty difficult to read what you have posted. Can you use rich formatting and post the code using "insert code using Syntaxhighlighter" option...

    Also you need to make sure there is resource assigned to PWM hw attribute. 

  • Hi Christin,

    Many thanks for your help so far. You are right, I have to put it just right before Bios_Start so that all the timers and task can run, to make PWM workable.

    I have successfully done the pwm.
    The file I used is provide by CC2640R2 simplelink_cc2640r2_sdk_1_00_00_22 inside folder pwmled.
    Only one function inside, it is the task function.


    I have study some TIRTOS and then start create a task. The LED attached to it can blink accordingly. I have also verify using a scope.

    Thank you so much.

    I have another question. For calculating the duty cycle. The software has provided :

    uint32_t duty = ( PWM_DUTY_FRACTION_MAX / 2 ); for 50 % duty cycle.
    params.dutyUnits = PWM_DUTY_FRACTION;


    However, I need to input percentage and not fraction. Therefore, I need a formula to calculate it.
    My formula is PWM_DUTY_FRACTION_MAX / (100 / user_input_percentage). But the microcontroller is unable to do calculation in fraction. Am I right ? Is there any api I can use to do this ? or any other alternative way ?

    Please help.

    Cheers,
    KF
  • Alrgiht, I am sorry about the layout. I will use Rich text nest time. I am not using it because I am still not very familiar to the forum environment here. Thank you very much for your help :)

    Cheers,
    KF
  • The supported units are Fraction, you can't just change to whatever you want without modifying the driver.
    I don't see the reason of using percentage since the fraction is already supported. It's just math, so I would recommend you to use fraction(so that you don't need to modify the driver)
  • Hi Christin,

    I have change the maths and it works. Thank you.

    Now I am facing another problem. Initially , originally, in the main has 2 task :
    GAPRole_createTask(); //Origianlly is priority 3.
    BridgeBLEPeripheral__CreateTask(); // Originally is 1, I have change the priority of this task to 5, which is the highest among all.

    Than I add a new task which is :
    Pwm__CreateTask(); // the priority is 1.


    If I only run Pwm__CreateTask();, (done by comment out the other 2 task ) , It is running and I observe it with breakpoint inside its for(;;) loop.


    But, then, I add back the other 2 task (, BridgeBLEPeripheral__CreateTask(); and GAPRole_createTask();) , or just either 1 of these task.


    After done this, my two other task ( BridgeBLEPeripheral__CreateTask(); and GAPRole_createTask();) does not operate.
    Program does not go into the Breakpoint inside for(;;) loop in ...Fxn function.


    Is it that there are still some other code I need to change in order to add more tasks ?
    I have change the constant ICALL_MAX_NUM_TASKS inside icall.c , but still the same problem exist.


    Is TIRTOS operates very similar to FreeRTOS ?



    Please advice.
    Thank you very much.


    Cheers,

    KF
  • Hi Christin,

    I have change the maths and it works.  Thank you.

    Now I am facing another problem.  Initially , originally, in the main has 2 task :

    GAPRole_createTask();  //Origianlly is priority 3.

    BridgeBLEPeripheral__CreateTask();  // Originally is 1,  I have change the priority of this task to 5, which is the highest among all.

    Than I add a new task which is : 

    Pwm__CreateTask();  // the priority is 1.

    If I only run Pwm__CreateTask();,  (done by comment out the other 2 task ) , It is running and I observe it with breakpoint inside its for(;;) loop.

    But, then, I add back the other 2 task (, BridgeBLEPeripheral__CreateTask();   and GAPRole_createTask();) ,  or just either 1 of these task.

    After done this, my two other task  ( BridgeBLEPeripheral__CreateTask();   and GAPRole_createTask();)   does not operate. 

    Program does not go into the Breakpoint inside for(;;) loop in ...Fxn function.

    Is it that there are still some other code I need to change in order to add more tasks ?

    I have change the constant ICALL_MAX_NUM_TASKS   inside icall.c , but still the same problem exist.

    Is TIRTOS operates very similar to FreeRTOS ?

    Please advice.

    Thank you very much.

    Cheers,

    KF 

  • Hi Christin,

    I have change the maths and it works.  Thank you.

    Now I am facing another problem.  Initially , originally, in the main has 2 task :

    GAPRole_createTask();  //Origianlly is priority 3.

    BridgeBLEPeripheral__CreateTask();  // Originally is 1,  I have change the priority of this task to 5, which is the highest among all.

    Than I add a new task which is : 

    Pwm__CreateTask();  // the priority is 1.

    If I only run Pwm__CreateTask();,  (done by comment out the other 2 task ) , It is running and I observe it with breakpoint inside its for(;;) loop.

    But, then, I add back the other 2 task (, BridgeBLEPeripheral__CreateTask();   and GAPRole_createTask();) ,  or just either 1 of these task.

    After done this, my two other task  ( BridgeBLEPeripheral__CreateTask();   and GAPRole_createTask();)   does not operate. 

    Program does not go into the Breakpoint inside for(;;) loop in ...Fxn function.

    Is it that there are still some other code I need to change in order to add more tasks ?

    I have change the constant ICALL_MAX_NUM_TASKS   inside icall.c , but still the same problem exist.

    Is TIRTOS operates very similar to FreeRTOS ?

    Please advice.

    Thank you very much.

    Cheers,

    KF 

  • You are not supposed to have your application task higher than gap-role and BLE stack. Please make sure your application is at priority 1 or lower(0) and then you can use a semaphore post from the simpleBLEPeripheral.c

    Please take a look at our software developer's guide TI-RTOS section.
  • Hi Christin,

    Many thanks for your advice.

    I will explore on using semaphore in TIRTOS and implement it.

    But, may I ask, must I use semaphore ?  If I implement my 2 example task (simple_peripheral and my_pwm ) to priority 1, will it work ?

    The reason is, for priority 1, both 2 example tasks will be allocate the same chance to execute by TIRTOS. 

    Since it works with simple_peripheral alone, should it works also with other added task (same priority with simple_peripheral) ?

    Please advice.

    Thank you very much.

    Cheers,

    KF

  • If you don't use semaphore to pend the event(or event pend), then the first priority 1 task got executed will run forever, which means the other one will not be executed at all.

    I recommend you to spend 1 day finishing up simplelink_academy training. Most of the question you asked which took you more than 1 day to solve are already explained in the training.

    Finishing the training will benefit you a lot than just try and error.  Even though the training is for R1 device but the structure and the concept is the same.

    You can download simplelink academy training here :
    software-dl.ti.com/.../overview.html

  • Hi Christin,

    Thank you very much.

    I have study about Real Time Operating System in general but not specific to TIRTOS.
    While I am doing debug now,  I will gain access to videos and Kernel document to explore more on TIRTOS.

    Now, I have add a semaphore to the function call event_pend, to one of my task, which I modify from pwmled.c:
    void Pwm__taskFxn(UArg a0, UArg a1)
    {
    .
    .
    .
        for(;;)
        {
            uint32_t events;
            //events = Event_pend(pwmLedSem, Event_Id_NONE, PWM_ALL_EVENTS, ICALL_TIMEOUT_FOREVER);
            events = Event_pend(pwmLedSem, Event_Id_NONE, PWM_ALL_EVENTS, ICALL_TIMEOUT_PREDEFINE);
            /* [kf] Defination : int_fast16_t PWM_setDuty(PWM_Handle handle, uint32_t duty) */
            PWM_setDuty(pwm1, dutyUs);
        }
    }

    From my understanding, Event_pend will check for my event handle " pwmLedSem" , which is a semaphore.

    By this setting, it will check for any event (PWM_ALL_EVENTS) available every ICALL_TIMEOUT_PREDEFINE seconds and then it will post a semaphore and then the task will be waken.

    By changing value of ICALL_TIMEOUT_PREDEFINE to longer time, execution will become slower, as observed when I put in a breakpoint at PWM_setDuty(...).

    While waiting for a semaphore to be give out by event_pend,  another task should be able to schedule to run.  This task is static void SimpleBLEPeripheral__TaskFxn(UArg a0, UArg a1).

    static void BridgeBLEPeripheral__TaskFxn(UArg a0, UArg a1)
    {
      /* [kf] Refer to CC26...SimpleLink BLE ... Developer's Guide.pdf, Pg. 66,
         Figure 4-3. SBP Task Flow Chart. */

      // Initialize application
      BridgeBLEPeripheral__Init(); /* [kf] Original, Commented for debug only */

      // Application main loop
      for (;;)
      {

        uint32_t events;
        events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS, ICALL_TIMEOUT_PREDEFINE);
    .
    .
    .
    .
    .
    .
    }

    }

    However, there program do not come into above function, as I observe with a breakpoint at BridgeBLEPeripheral__Init();  .  I have also change above function priority to 2.

    The program will go into static void gapRole_taskFxn(UArg a0, UArg a1), as I have observe with breakpoint inside the function.

    The program seems to go into only the last created task instead of all task.  It will continue execution of the last create task without giving out chance for other task.

    Does this means the task control block of the last created task is place at the front of the of the heap memory and will be execute first ?

    My current main() is describe as following:

      ICall_init();

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

      /* Kick off profile - Priority 3 */
      GAPRole_createTask();     /* [kf] No other Task can have a high priority than GAPRole Task */


      SimpleBLEPeripheral__CreateTask();

      /* [kf] Add in pwm task for debug */
      Pwm__CreateTask();  /* [kf] Uncomment to troubleshoot no advertising */

    }

    The SimpleBLEPeripheral task is executed first when I place it at the last created task, as shown in the following.

    This task will then take over the whole CPU and no letting other task to execute.

      ICall_init();

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

      /* Kick off profile - Priority 3 */
      GAPRole_createTask();     /* [kf] No other Task can have a high priority than GAPRole Task */

      /* [kf] Add in pwm task for debug */
      Pwm__CreateTask();  /* [kf] Uncomment to troubleshoot no advertising */

    SimpleBLEPeripheral__CreateTask();

    }

    Please help me o this issue.

    Beside, may I ask a question ? 

    semaphore can be use together with queue. 

    May I know what is event_pend ?  is it semaphoare also ?  is it a combination of semaphore and queue ? 

    Thank you very much.

    Please advice.

    Cheers,

    KF

  • Hi,

    You can find answers for your question in our software developer's guide. Also you can use TI-RTOS ROV viewer to check whether your tasks are blocked or not.
  • Hi Christin,

    Many thanks for your reply.
    This tools is for CCS only. But I am using IAR 7.80.

    May I have your advice ?

    Thank you very much.

    Cheers,
    KF
  • You can enable it by doing clicking the TI-RTOS box

  • Hi Christin,

    Thank you very much.  Unfortunately I do not have CSPY. This application need CSPY, is it ?.

    however, thank you very much and I will explore more into it.

      Thank you very much.

    Cheers,

    KF

  • Hi Christin,

    I am developing button function for my CC2640R2 project.  I am using CC2640R2 LAUNCHXL development board.

    My code for Button.c is based on sensortag_keys.c code. 

    However, may I know why when ever I  put in Semaphore_pend(ButtonSemaphore, BIOS_WAIT_FOREVER);  , my button interrupt will not work.

    If without Semaphore_pend(ButtonSemaphore, BIOS_WAIT_FOREVER); in my static void Button__TaskFxn(UArg a0, UArg a1), my interrupt will work.

    Which means, when button is pressed, program will goto my call back function  --->  void Button__Callback(PIN_Handle handle, PIN_Id pinId) . 

    This is initialised in PIN_registerIntCb(ButtonInteruptPinHandle, Button__Callback).

    The following is my code

    int main()
    {
    .
    .
    .
    .
    .
    
      /* [kf] Add in Button task for debug */
      Button__CreateTask();
    
      /* enable interrupts and start SYS/BIOS */
      BIOS_start();
    
      return 0;
    }
    
    
    
    void Button__CreateTask(void)
    {
      Task_Params taskParams;
    
      Task_Params_init(&taskParams);
      taskParams.stack = ButtonTaskStack;
      taskParams.stackSize = BUTTON_TASK_STACK_SIZE;
      taskParams.priority = BUTON_TASK_PRIORITY;
    
      Task_construct(&ButtonTask, Button__TaskFxn, &taskParams, NULL);
    }
    
    
    static void Button__TaskFxn(UArg a0, UArg a1)
    {
      uint8_t debugButton2;
      /* {kf] Initialize Button */
      Button__Init();
    
      // Application main loop
        for (;;)
        {
            uint32_t events;
    
                Semaphore_pend(ButtonSemaphore, BIOS_WAIT_FOREVER);
    
                debugButton2 = debugButton2 +1;
        }
    }
    
    
    void Button__Init(void)
    {
        Button__reset();
    
        ButtonInteruptPinHandle = PIN_open(&ButtonGpioState, ButtonPinTable);
        PIN_registerIntCb(ButtonInteruptPinHandle, Button__Callback);
    
        Util_constructClock(&periodicClock, Button__clockHandler,
                          100, 1000, false, 0);
    }
    
    
    void Button__Callback(PIN_Handle handle, PIN_Id pinId)
    {
      switch (pinId)
      {
    
          case Board_BTN2:
            Button__processKeyRight();
            break;
    
          default:
            /* Do nothing */
            break;
      }
    }
    
    
    void Button__processKeyRight(void)
    {
        uint8_t debugRbutton;
    
        if (PIN_getInputValue(Board_KEY_RIGHT))
        {
            keys &= ~SK_KEY_RIGHT;
        }
        else
        {
            keys |= SK_KEY_RIGHT;
        }
    
        Semaphore_post(ButtonSemaphore);
    
        debugRbutton = debugRbutton + debugRbutton;
    }

    When button is pressed, program is not going to void Button__processKeyRight(void) to process its data.

    Please advice.

    Thank you very much.

    Cheers,

    KF

     

  • Thanks Christin and others for advice so far. I have made a mistakes. I forgotten to create the semaphore. It is now working.
    May I know how to set the maximum count of the counting semaphore ?

    Thank you for your advice.

    Cheers,
    KF
  • Hi Christin,

    I am also facing same "sendWaitMatchCS(ICall_getEntityId(), msg, matchGapSetParamCS);"


    I am using,

    CCS Version - 7.1.0.00016

    BLE Stack 2.2.1

    Example code from 

    To test the maximum Throughtput between two boards. Here - i loaded the peripheral stack and application code.


    Here i attached the images to help to understand more about my code.

    the above images are shows the flow of the program.

    and the struck is happening inside the 5th function 

    Inside this function = static bStatus_t sendWaitMatchCS(ICall_EntityID src, void *msg, ICall_MsgMatchFn matchCSFn)

    "waitMatchCS(matchCSFn, (void **)&pCmdStatus);" is not giving any return response.

    inside "WaitMatchCS" function its struck in return "ICALL_ERRNO_UNKNOWN_THREAD;" 

    Could Please help me now?