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.

RTOS/CC2640R2F: Program not able to create mainThread. Stuck at Error.policyDefault/policySpin exception

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hello 

I am using microeddystoneBeacon program in SDK 1.35 because it fits my application. I am using a custom module of theCC2640R2F from TI approved vendor. I have created one mainThread() which calls the task for MEB application start and incorporates a UART read with low Power mode

However, the intial pthread_create() is not able to create the mainThread and the code is stuck in while(1). 

I am attaching a picture of the same here. I read on a previous thread that the posix paths and variables have to be included. So I did that. I included the path from the sdk. Plus in my file app_ble.cfg I've also put the following:

utils.importFile("common/cc26xx/kernel/cc2640/config/cc2640_r2_csdk.cfg");

var Settings = xdc.useModule('ti.sysbios.posix.Settings');

var Error = xdc.useModule('xdc.runtime.Error');
Error.policyFxn = Error.policyDefault;
Error.raiseHook = Error.print;
Error.maxDepth = 2;

So that it finds the path for the same. All necessary files like pthread.h etc have been included in main.c wrt other driver programs that use a mainThread. Driver codes execute perfectly for me with the above config. However, there is a problem with all the BLE programs in blestack as well as blestack5. Can somebody help me with this?

Thanks 

Shubhankar

  • Hi Shubhankar,

    Is there a reason you are using the 1.35 SDK? I would highly recommend you to try moving to the newer 2.30 SDK to get the latest fixes and features.

    Regarding your POSIX problem, a few things come to mind, the first is that you simply do not have enough heap in the application as pthread_create depends on a heap to allocate the stack.

    The second one is that you would also need to modify your TI-RTOS build, if you have not done this already, to support POSIX. This is described in this Simplelink Acadamy training (written for the 2.30 SDK):

    dev.ti.com/.../
  • Hello M-W

    1. Reason I'm using 1.35 is because it is specified by the TI approved vendor in porting to his RHB package module

    2. Yes I changed the stack size to 1024 and now the code enters the main thread! I realised that 2048 was too great a value

    3. My application consists of reading from UART wakeup on the Rx pin and then advertising the MEB for about 10 seconds and then going back to sleep to receive the next interrupt.

    In my present code my sleep current is about 5 uA and broadcast current around 250 uA. However, after the first broadcast the device keeps broadcasting indefinitely and doesn't go to sleep. 

    static void MicroEddystoneBeacon_startBroadcast(void)
    {
      uint8 tempPower;
    
      ub_getParameter(UB_PARAM_TXPOWER, &tempPower);
      eddystoneUID.rangingData = tempPower;
      eddystoneURL.txPower = tempPower;
    
      // Select UID or URL frame as adv data initially
      MicroEddystoneBeacon_updateAdvDataWithFrame(currentFrameType);
    
     ug_bcastStart(1); /* Broadcaster will stop after 100th Adv event */
     //ug_bcastStart(0); /* Broadcaster runs indefinitely */
     ug_bcastStop();
    
    }
    
    void *mainThread()
    {
    while(1)
        {
            /* Wait until it is time to wake-up */
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
            /* If we are to go into standby, close the UART and reconfigure the pin */
               if(goToStandby)
               {
                   /* Go back to sleep */
                   UART_close(uartHandle);
    
                   /* Reconfigure the PIN interrupt */
                   /* Add RX pin back to the PIN driver */
                   
    
                   /* Register callback */
                   
    
                   goToStandby = 0;
                   transmitFlag = 1;
               }
    
               if (transmitFlag == 1)
                  {
                               CPUdelay(8000*50);
                          
                               MicroEddystoneBeacon_taskFxn(); //this function starts the chain of events
    
                          transmitFlag = 0;
                        }
               
        }}
    
    

    So I commented the indefinite broadcast, made the number of advertising events 1 and stopped the broadcast. However, after this the code goes into the UART loop, broadcasts once, then the process never repeats and the code is stuck in a register(not in an exception handler). The beacon also does not advertise What do I do to resolve this?

  • Hello M-W

    I think the tricky part lies in the function MicroEddystoneBeacon_taskFxn. It pends on an Event and I think unless there is a post, the broadcast does not stop. Also there is a queue that the RTOS waits on in 

    MicroEddystoneBeacon_processAppMsg. I haven't quite understood what the latter does. I tried an Event_post after the free(pMsg) but it did not work out. Any insights?

    Best Regards

    Shubhankar

  • Hi Shubhankar,

    I'm not that familiar with the MicroEddystoneBeacon example and how it works. I would recommend you to branch this thread of using the "Ask a related question" so that someone with more expertise on this area could help you.