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.

CC2640: All tasks get blocked shortly after wake-up from a sleep/standby state

Part Number: CC2640
Other Parts Discussed in Thread: SYSBIOS, BLE-STACK

I have a big complex ProjectZero based project that includes 2 periodic cycle clocks (one at 1ms and one at 2000ms) , an external flash, I2C and UART code.

The code works well communicating with a UART device, four I2C devices, external flash and a BLE IOS App which I developed.

I have just recently been able to initiate a sleep/standby state of <10ua current after I sense that 2.8v has been removed from IOID_14 by stopping my periodic cycle clocks, stopping advertising on BLE plus closing all my pins, I2C, and UART.

Wakeup from sleep is triggered by an interrupt of IOID_14 when 2.8v is applied to the pin, at which point I restart my periodic cycle clocks, reopen all my pins/I2C/UART and start advertising on BLE again.

I have coded a yellow LED to only ever come on for 2 seconds (and then goes off) each time that the main.c main() function is run. This lets me know if there is a problem waking up that initiates the main() function code as in a restart that will start the RTC from zero and initialize all ram variables again (both of which should not occur after waking from sleep).

Running stand alone without debugging in CSS by JTAG cable, I apply 2.8 volts on IOID_14 during this <10ua sleep state and the Yellow LED comes on for 2 seconds. This is not an expected behavior.

To debug this issue I run a CCS debug session, run the code and then:

  1. Initiate the sleep by removing 2.8v from IOID_14
  2. I enable a breakpoint at a point where my 1ms periodic cycle clock trigger has been recognized in my ProjetZero_taskFxn loop.
  3. Apply 2.8v to IOID_14. At which point the code execution breaks at my enabled breakpoint which indicates that the pin interrupt has occurred, my ProjetZero_taskFxn loop has started again and my 1ms periodic cycle clock has triggered.
  4. I then begin single stepping through the code with F5 and after a few steps my code stops executing however the code stills runs/pauses and be continued.
  5. When I pause in this 'hung' state I am able to use ROV to see that an Hard Fault: FORCED: USAGE: NOCP exception has occurred:

Most of the time in this 'hung' state is spent looping through the above 4 lines 1001b180 to 1001b188.

Here is a disassembly listing with RTOS ROV symbols added for an area just before that loop and up the the line where the loop exits to once in a while:

          ti_sysbios_knl_Task_schedule__I():
1001b174:   B570                push       {r4, r5, r6, lr}
1001b176:   4C11                ldr        r4, [pc, #0x44]
1001b178:   2600                movs       r6, #0
1001b17a:   25F8                movs       r5, #0xf8
          $C$L37:
1001b17c:   8126                strh       r6, [r4, #8]
1001b17e:   E001                b          $C$L39
          $C$L38:
1001b180:   F000F8F0            bl         #0x1001b364
          $C$L39:
1001b184:   6860                ldr        r0, [r4, #4]
1001b186:   2800                cmp        r0, #0
1001b188:   D0FA                beq        $C$L38
1001b18a:   6860                ldr        r0, [r4, #4]
1001b18c:   69A3                ldr        r3, [r4, #0x18]
1001b18e:   6962                ldr        r2, [r4, #0x14]
1001b190:   FAB0F080            clz        r0, r0
1001b194:   EBA501C0            sub.w      r1, r5, r0, lsl #3
1001b198:   1858                adds       r0, r3, r1
1001b19a:   4282                cmp        r2, r0
1001b19c:   D20A                bhs        $C$L40
1001b19e:   6922                ldr        r2, [r4, #0x10]
1001b1a0:   6160                str        r0, [r4, #0x14]
1001b1a2:   F001F897            bl         #0x1001c2d4
1001b1a6:   4601                mov        r1, r0
1001b1a8:   6121                str        r1, [r4, #0x10]
1001b1aa:   F1020010            add.w      r0, r2, #0x10
1001b1ae:   3110                adds       r1, #0x10
1001b1b0:   F001F8A4            bl         #0x1001c2fc
          $C$L40:
1001b1b4:   8920                ldrh       r0, [r4, #8]
1001b1b6:   2800                cmp        r0, #0
1001b1b8:   D1E0                bne        $C$L37
1001b1ba:   BD70                pop        {r4, r5, r6, pc}
          $C$CON34:
1001b1bc:   0100                lsls       r0, r0, #4
1001b1be:   2000                movs       r0, #0
          ti_sysbios_family_arm_m3_Hwi_Module_startup__E():
1001b1c0:   B570                push       {r4, r5, r6, lr}
1001b1c2:   2020                movs       r0, #0x20
1001b1c4:   F3808811           .word       0x8811f380
1001b1c8:   4A0D                ldr        r2, [pc, #0x34]
1001b1ca:   6991                ldr        r1, [r2, #0x18]
1001b1cc:   6950                ldr        r0, [r2, #0x14]
1001b1ce:   F04F35FF            mov.w      r5, #-1
1001b1d2:   F0200007            bic        r0, r0, #7
1001b1d6:   1809                adds       r1, r1, r0
1001b1d8:   480A                ldr        r0, [pc, #0x28]
1001b1da:   6015                str        r5, [r2]
1001b1dc:   3908                subs       r1, #8
1001b1de:   6804                ldr        r4, [r0]
1001b1e0:   6111                str        r1, [r2, #0x10]
1001b1e2:   2C00                cmp        r4, #0
1001b1e4:   DD0A                ble        $C$L565
1001b1e6:   2600                movs       r6, #0
          $C$L564:
1001b1e8:   2000                movs       r0, #0
1001b1ea:   4631                mov        r1, r6
1001b1ec:   F000FAE8            bl         #0x1001b7c0
1001b1f0:   2100                movs       r1, #0
1001b1f2:   F7FFF891            bl         #0x1001a318
1001b1f6:   1C76                adds       r6, r6, #1
1001b1f8:   1E64                subs       r4, r4, #1
1001b1fa:   D1F5                bne        $C$L564
          $C$L565:
1001b1fc:   4628                mov        r0, r5
1001b1fe:   BD70                pop        {r4, r5, r6, pc}
          $C$CON631:
1001b200:   0144                lsls       r4, r0, #5
1001b202:   2000                movs       r0, #0
          $C$CON633:
1001b204:   0494                lsls       r4, r2, #0x12
1001b206:   0000                movs       r0, r0
          ti_sysbios_heaps_HeapMem_getStats__E():
1001b208:   B570                push       {r4, r5, r6, lr}
1001b20a:   4605                mov        r5, r0
1001b20c:   6928                ldr        r0, [r5, #0x10]
1001b20e:   460C                mov        r4, r1
1001b210:   6020                str        r0, [r4]
1001b212:   2000                movs       r0, #0
1001b214:   6060                str        r0, [r4, #4]
1001b216:   60A0                str        r0, [r4, #8]
1001b218:   480C                ldr        r0, [pc, #0x30]
1001b21a:   6806                ldr        r6, [r0]
1001b21c:   4630                mov        r0, r6
1001b21e:   F001F83D            bl         #0x1001c29c
1001b222:   4601                mov        r1, r0
1001b224:   68E8                ldr        r0, [r5, #0xc]
1001b226:   B160                cbz        r0, #0x1001b242
1001b228:   6862                ldr        r2, [r4, #4]
1001b22a:   68A3                ldr        r3, [r4, #8]
          $C$L421:
1001b22c:   6845                ldr        r5, [r0, #4]
1001b22e:   18AA                adds       r2, r5, r2
1001b230:   6062                str        r2, [r4, #4]
1001b232:   6845                ldr        r5, [r0, #4]
1001b234:   429D                cmp        r5, r3
1001b236:   BF84                itt        hi
1001b238:   1C2B                adds       r3, r5, #0
1001b23a:   60A3                str        r3, [r4, #8]
1001b23c:   6800                ldr        r0, [r0]
1001b23e:   2800                cmp        r0, #0
1001b240:   D1F4                bne        $C$L421
          $C$L422:
1001b242:   4630                mov        r0, r6
1001b244:   F001F82C            bl         #0x1001c2a0
1001b248:   BD70                pop        {r4, r5, r6, pc}
1001b24a:   46C0                mov        r8, r8
          $C$CON442:
1001b24c:   04B8                lsls       r0, r7, #0x12
1001b24e:   0000                movs       r0, r0
          ti_sysbios_knl_Mailbox_Module_startup__E():
1001b250:   4810                ldr        r0, [pc, #0x40]
1001b252:   B538                push       {r3, r4, r5, lr}
1001b254:   6804                ldr        r4, [r0]
1001b256:   2C00                cmp        r4, #0
1001b258:   DD19                ble        $C$L367
1001b25a:   2500                movs       r5, #0
          $C$L364:
1001b25c:   2000                movs       r0, #0
1001b25e:   4629                mov        r1, r5
1001b260:   F000FB1C            bl         #0x1001b89c
1001b264:   4602                mov        r2, r0
1001b266:   68D0                ldr        r0, [r2, #0xc]
1001b268:   B948                cbnz       r0, #0x1001b27e
1001b26a:   F001FAF5            bl         #0x1001c858
1001b26e:   6851                ldr        r1, [r2, #4]
1001b270:   1840                adds       r0, r0, r1
1001b272:   1DC1                adds       r1, r0, #7
1001b274:   F001FAF0            bl         #0x1001c858
1001b278:   1E40                subs       r0, r0, #1
1001b27a:   4381                bics       r1, r0
1001b27c:   E001                b          $C$L366
          $C$L365:
1001b27e:   6851                ldr        r1, [r2, #4]
1001b280:   3108                adds       r1, #8
          $C$L366:
1001b282:   4610                mov        r0, r2
1001b284:   F000FB20            bl         #0x1001b8c8
1001b288:   1C6D                adds       r5, r5, #1
1001b28a:   1E64                subs       r4, r4, #1
1001b28c:   D1E6                bne        $C$L364
          $C$L367:
1001b28e:   F04F30FF            mov.w      r0, #-1
1001b292:   BD38                pop        {r3, r4, r5, pc}
          $C$CON355:
1001b294:   04CC                lsls       r4, r1, #0x13
1001b296:   0000                movs       r0, r0
          ti_sysbios_family_arm_m3_Hwi_disableInterrupt__E():
1001b298:   4A0F                ldr        r2, [pc, #0x3c]
1001b29a:   2810                cmp        r0, #0x10
1001b29c:   D20B                bhs        $C$L14
1001b29e:   280F                cmp        r0, #0xf
1001b2a0:   BF18                it         ne
1001b2a2:   2000                movs       r0, #0
1001b2a4:   D115                bne        $C$L15
1001b2a6:   6910                ldr        r0, [r2, #0x10]
1001b2a8:   6911                ldr        r1, [r2, #0x10]
1001b2aa:   F0000002            and        r0, r0, #2
1001b2ae:   F0210102            bic        r1, r1, #2
1001b2b2:   6111                str        r1, [r2, #0x10]
1001b2b4:   E00D                b          $C$L15
          $C$L14:
1001b2b6:   3810                subs       r0, #0x10
1001b2b8:   2101                movs       r1, #1
1001b2ba:   F000031F            and        r3, r0, #0x1f
1001b2be:   08C0                lsrs       r0, r0, #3
1001b2c0:   4099                lsls       r1, r3
1001b2c2:   F0200003            bic        r0, r0, #3
1001b2c6:   1812                adds       r2, r2, r0
1001b2c8:   F8D20100            ldr.w      r0, [r2, #0x100]
1001b2cc:   F8C21180            str.w      r1, [r2, #0x180]
1001b2d0:   4008                ands       r0, r1
          $C$L15:
1001b2d2:   BF00                nop        
1001b2d4:   4770                bx         lr
1001b2d6:   46C0                mov        r8, r8
          $C$CON4:
1001b2d8:   E000                b          ti_sysbios_family_arm_m3_Hwi_enableInterrupt__E
1001b2da:   E000                b          #0x1001b2de
          ti_sysbios_family_arm_m3_Hwi_enableInterrupt__E():
1001b2dc:   4A0F                ldr        r2, [pc, #0x3c]
1001b2de:   2810                cmp        r0, #0x10
1001b2e0:   D20B                bhs        $C$L450
1001b2e2:   280F                cmp        r0, #0xf
1001b2e4:   BF18                it         ne
1001b2e6:   2000                movs       r0, #0
1001b2e8:   D115                bne        $C$L451
1001b2ea:   6910                ldr        r0, [r2, #0x10]
1001b2ec:   6911                ldr        r1, [r2, #0x10]
1001b2ee:   F0000002            and        r0, r0, #2
1001b2f2:   F0410102            orr        r1, r1, #2
1001b2f6:   6111                str        r1, [r2, #0x10]
1001b2f8:   E00D                b          $C$L451
          $C$L450:
1001b2fa:   3810                subs       r0, #0x10
1001b2fc:   2101                movs       r1, #1
1001b2fe:   F000031F            and        r3, r0, #0x1f
1001b302:   08C0                lsrs       r0, r0, #3
1001b304:   4099                lsls       r1, r3
1001b306:   F0200003            bic        r0, r0, #3
1001b30a:   1812                adds       r2, r2, r0
1001b30c:   F8D20100            ldr.w      r0, [r2, #0x100]
1001b310:   F8C21100            str.w      r1, [r2, #0x100]
1001b314:   4008                ands       r0, r1
          $C$L451:
1001b316:   BF00                nop        
1001b318:   4770                bx         lr
1001b31a:   46C0                mov        r8, r8
          $C$CON471:
1001b31c:   E000                b          ti_sysbios_knl_Swi_post__E
1001b31e:   E000                b          #0x1001b322
          ti_sysbios_knl_Swi_post__E():
1001b320:   B538                push       {r3, r4, r5, lr}
1001b322:   4603                mov        r3, r0
1001b324:   F3EF8411           .word       0x8411f3ef
1001b328:   2020                movs       r0, #0x20
1001b32a:   F3808811           .word       0x8811f380
1001b32e:   8B98                ldrh       r0, [r3, #0x1c]
1001b330:   B998                cbnz       r0, #0x1001b35a
1001b332:   2001                movs       r0, #1
1001b334:   8398                strh       r0, [r3, #0x1c]
1001b336:   F000FECD            bl         #0x1001c0d4
1001b33a:   4605                mov        r5, r0
1001b33c:   6A98                ldr        r0, [r3, #0x28]
1001b33e:   4619                mov        r1, r3
1001b340:   F000FF38            bl         #0x1001c1b4
1001b344:   4906                ldr        r1, [pc, #0x18]
1001b346:   6998                ldr        r0, [r3, #0x18]
1001b348:   684A                ldr        r2, [r1, #4]
1001b34a:   4310                orrs       r0, r2
1001b34c:   6048                str        r0, [r1, #4]
1001b34e:   F3848811           .word       0x8811f384
1001b352:   B925                cbnz       r5, #0x1001b35e
1001b354:   F7FFFE6C            bl         #0x1001b030
1001b358:   BD38                pop        {r3, r4, r5, pc}
          $C$L305:
1001b35a:   F3848811           .word       0x8811f384
          $C$L306:
1001b35e:   BD38                pop        {r3, r4, r5, pc}
          $C$CON248:
1001b360:   01C8                lsls       r0, r1, #7
1001b362:   2000                movs       r0, #0
          ti_sysbios_knl_Task_allBlockedFunction__I():
1001b364:   B508                push       {r3, lr}

From that listing it appears that code is sometimes transitioning from ti_sysbios_knl_Task_schedule__I to ti_sysbios_knl_Task_allBlockedFunction__I.

Which seems to indicate that all tasks are blocked during this 'hung' state.

During this 'hung' state ROV supports this 'all tasks blocked' status by these images:

Can someone please help and/or perhaps suggest how to investigate the task scheduler and determine how/why all tasks revert to blocked after waking up?

Thanks,

Dale

NOTE: Here is the point in another topic where this issue was first discovered/discussed and eventually a decision was made to start this new topic:

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1109571/cc2640-minimizing-sleep-current-when-using-i2c-and-uart/4147714#4147714

  • Here is screenshot showing the code breaks, after wakeup is triggered, where my 1ms periodic cycle clock trigger has been recognized in my ProjectZero_taskFxn loop:

    This is as expected since this breakpoint would not be reached if ProjectZero_taskFxn were blocked.

    Only a few single steps after this, the code execution will enter the 'hung' state with all tasks blocked again.

     

  • Hey Dale,

    Thanks for the post. Can you highlight how you are resuming each task?

    Is it possible to narrow the scope of this issue by testing just the restart mechanism on the pin interrupt outside of the BLE-stack? By the description, I suspect this issue may not be specifically associated with the BLE-stack. However, depending on how things are designed to "restart", you may run into a bad state.

    Have you seen any HWI exceptions or asserts or anything like this when the issue occurs?

  • Hi Ammar,

    Thanks for the post. Can you highlight how you are resuming each task?

    1st my interrupt code is trigger by a 2.8v rising edge trigger on IOID_14 which enters this code:

    static void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId)
    {
      buttonWAKEstate = (uint8_t) PIN_getInputValue(pinId); //p2f16-18 testing
    
      // Disable interrupt on that pin for now. Re-enabled after debounce.
      PIN_setConfig(handle, PIN_BM_IRQ, pinId | PIN_IRQ_DIS);
    
      // Start debounce timer
      switch (pinId)
      {
        case Board_HasVoltsOnWakeInput:
          Clock_start(Clock_handle(&buttonWakeDebounceClock));
          break;
      }
    }

    Which in turn starts a 2 second clock that will ensure that the 2.8v is still there after 2 seconds, here is the code that runs when the 2 seconds is up:

    static void buttonDebounceSwiFxn(UArg buttonId)
    {
      // Used to send message to app
      button_state_t buttonMsg = { .pinId = buttonId };
      uint8_t        sendMsg   = FALSE;
    
      // Get current value of the button pin after the clock timeout
      uint8_t buttonPinVal = PIN_getInputValue(buttonId);
    
      // Set interrupt direction to opposite of debounced state
      // If button is now released (button is active low, so release is high) //
      if (buttonPinVal)
      {
        // Enable negative edge interrupts to wait  //p2f16-18 for removal of volts TOOK OUT for press
        PIN_setConfig(buttonPinHandle, PIN_BM_IRQ, buttonId | PIN_IRQ_NEGEDGE);
      }
      else
      {
        // Enable positive edge interrupts to wait  //p2f16-18 for an apply volts TOOK OUT for release
        PIN_setConfig(buttonPinHandle, PIN_BM_IRQ, buttonId | PIN_IRQ_POSEDGE);
      }
    
      switch(buttonId)
      {
        case Board_HasVoltsOnWakeInput:
          // If button is now released (buttonPinVal is active low, so release is 1)
          // and button state was pressed (buttonstate is active high so press is 1)
          if (buttonPinVal && buttonWAKEstate)
          {
            //  we DO have volts
            buttonMsg.state = buttonWAKEstate = 1; //p2f16-18 0 to 1
            sendMsg = TRUE;
          }
          else if (!buttonPinVal && !buttonWAKEstate)
          {
            //  we DON'T have volts
            buttonMsg.state = buttonWAKEstate = 0; //p2f16-18 1 to 0
            sendMsg = TRUE;
          }
          break;
      }
    
      if (sendMsg == TRUE)
      {
        user_enqueueRawAppMsg(APP_MSG_BUTTON_DEBOUNCED,
                          (uint8_t *)&buttonMsg, sizeof(buttonMsg));
      }
    }

    If the voltage is still there after 2 seconds then a message is sent on the user_enqueueRawAppMsg() and is received with this code:

    static void user_enqueueRawAppMsg(app_msg_types_t appMsgType, uint8_t *pData,
                                      uint16_t len)
    {
      // Allocate memory for the message.
      app_msg_t *pMsg = ICall_malloc( sizeof(app_msg_t) + len );
    
      if (pMsg != NULL)
      {
        pMsg->type = appMsgType;
    
        // Copy data into message
        memcpy(pMsg->pdu, pData, len);
    
        // Enqueue the message using pointer to queue node element.
        Queue_enqueue(hApplicationMsgQ, &pMsg->_elem);
        // Let application know there's a message.
        Semaphore_post(sem);
      }
    }

    Which posts the message by semaphore and is received here:

    static void user_processApplicationMessage(app_msg_t *pMsg)
    {
      char_data_t *pCharData = (char_data_t *)pMsg->pdu;
    
      switch (pMsg->type)
      {
        case APP_MSG_SERVICE_WRITE: /* Message about received value write */
          /* Call different handler per service */
          switch(pCharData->svcUUID) {
            case HALO_SERVICE_SERV_UUID:
              user_HaloService_ValueChangeHandler(pCharData);
              break;
          }
          break;
    
        case APP_MSG_SERVICE_CFG: /* Message about received CCCD write */
          /* Call different handler per service */
          switch(pCharData->svcUUID) {
            case HALO_SERVICE_SERV_UUID:
              user_HaloService_CfgChangeHandler(pCharData);
              break;
          }
          break;
    
        case APP_MSG_UPDATE_CHARVAL: /* Message from ourselves to send  */
          user_updateCharVal(pCharData);
          break;
    
        case APP_MSG_GAP_STATE_CHANGE: /* Message that GAP state changed  */
          user_processGapStateChangeEvt( *(gaprole_States_t *)pMsg->pdu );
          break;
    
        case APP_MSG_SEND_PASSCODE: /* Message about pairing PIN request */
          {
            passcode_req_t *pReq = (passcode_req_t *)pMsg->pdu;
            Log_info2("BondMgr Requested passcode. We are %s passcode %06d",
                      (IArg)(pReq->uiInputs?"Sending":"Displaying"),
                      DEFAULT_PASSCODE);
            // Send passcode response.
            GAPBondMgr_PasscodeRsp(pReq->connHandle, SUCCESS, DEFAULT_PASSCODE);
          }
          break;
    
        case APP_MSG_BUTTON_DEBOUNCED: /* Message from swi about pin change */
          {
            button_state_t *pButtonState = (button_state_t *)pMsg->pdu;
            user_handleButtonPress(pButtonState);
          }
          break;
      }
    }

    Which then calls user_handleButtonPress(pButtonState) :

    static void user_handleButtonPress(button_state_t *pState)
    {
      switch (pState->pinId)
      {
        case Board_HasVoltsOnWakeInput:
            checkForWakeVolts(); //this is where we get woken up from sleep with an interrupt!!!!
            break;
      }
    }

    Which finally calls my checkForWakeVolts() function which should restart all the tasks:

    static void checkForWakeVolts(void){    //after interrupt wakeup and every 2 seconds in the main loop we check if WE HAVE ANY
                                            // of 2.8v on IOID_14 from 12v divider or 5v divider or from a closed reed switch
                                            // we then openpins, start UART, I2C, start cycleclocks and start to advertise
                                            // OR if we don't have volts AND we are NOT fogging, then we GOTOSLEEP
    
            if (PIN_getInputValue(Board_HasVoltsOnWakeInput) == 1 && areweawake == 0) { //if WE HAVE ANY 2.8v and we are asleep
    
                //openPins(); //the 6 lines in this function have been added below here
                if(!buttonPinHandle) buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable); //IOID_14
                if(!tPinHandle) tPinHandle = PIN_open(&tPinState, tPinTable); //IOID_0
                if(!rhPinHandle) rhPinHandle = PIN_open(&rhPinState, rhPinTable); //IOID_1
                if(!redPinHandle) redPinHandle = PIN_open(&redPinState, redPinTable); //IOID_11
                if(!v33PinHandle) v33PinHandle = PIN_open(&v33PinState, v33PinTable); //IOID_2
                if(!ledPinHandle) ledPinHandle = PIN_open(&ledPinState, ledPinTable); //IOID_12 compressor            
    
                //UARTcloseopen(); //p2f16-27 (HAD TO TAKE THIS OUT FOR WAKEUP TOPIC and put it before main loop starts)
                // because if this is called after wakeup, then JTAG disconnect happens instantly in the middle of UARTcloseopen()
    
                initI2CdevicesAndGetUID();  //also turns 2.7 volts back on the pullups when we wakeup
                
                areweawake= 1;
    
                setNextemptyAndTTandRepairDB(1);     //p2f14-34 sets current last record and repairs database if nercessary whenever we wakeup (FOG or POD)
                                                     //call setNextemptyAndTTandRepairDB(1) and the 1 means that we have just woken up and we must fix all events with on or off of 0xFFFFFFFF
                Util_restartClock(&periodic_1ms_cycleClock, PERIODIC_1MS_CYCLE_PERIOD);
                Util_restartClock(&periodic_checkwake_cycleClock, PERIODIC_CHECKWAKE_CYCLE_PERIOD);
                GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, 1, &areweawake ); // start BLE advertising
                Task_sleep(wfor/Clock_tickPeriod);  //35 ms may not be needed
                
            }else if (PIN_getInputValue(Board_HasVoltsOnWakeInput) == 0 && areweawake == 1) { //if NO 2.8v on IOID_14 AND we are awake, then we go to sleep if we are NOT fogging
                    gotosleep();    //close pins, close UART and I2C, periodic cycle clocks, try to stop a BLE connection and stop advretising
            }
    }

    Is it possible to narrow the scope of this issue by testing just the restart mechanism on the pin interrupt outside of the BLE-stack?

    I tried NOT starting to advertise again after waking up (remmed out that line in my checkForWakeVolts function) but the 'hang' state behavior was the same.

    Have you seen any HWI exceptions or asserts or anything like this when the issue occurs?

    The only HWI exception I have seen is shown in the first image of this topic and the 5 exceptions in the ROV BIOS listing a few images below that. (BOLD here is an edit)

    A breakpoint on the first line of main.c AssertHandler() function is never triggered during the debug session that results in the 'hang' state.

    I hope I have given the info you requested, if I did not understand the questions please ask again...

    Thanks,

    Dale

  • Hey Dale,

    I apologize for the delay. Thanks for clarifying the flow of operations. I'm a bit confused on the issue we are tackling.

    I have coded a yellow LED to only ever come on for 2 seconds (and then goes off) each time that the main.c main() function is run. This lets me know if there is a problem waking up that initiates the main() function code as in a restart that will start the RTC from zero and initialize all ram variables again (both of which should not occur after waking from sleep).

    Here you mention that main.c is entered twice, indicating that the device must have reset? Have you set some sort of watchdog? Am I misunderstanding the setup here? Can this scenario be reproduced in a simple example project (showcasing just the pin interrupt and sleep/wakeup sequence)?

    Maybe the answer to this will help me understand further. What happens if there is no logic inside checkForWakeVolts?