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.

Task Blocked "Unknown"

Other Parts Discussed in Thread: CC1310

Hi,

    I'm using the RF Packet TX and Pin interrupt examples to send a packet when a button interrupt the cc1310.

   I created a task for TX packet and a semaphore that activate the task when button has been pushed.

   The application work fine if i push the button frequently, but if i wait for some minutes the task blocked by unknown (in ROV). The button interrupt callback function executed correctly but the TXTask "blocked by unknown".

Why happend this?

   I use " Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);" so the task could be waiting forever until a "Semaphore_post".

Best regards.

  • It sounds like a corruption problem. Can you do a "scan for errors..." in ROV->BIOS? Check it in main, right before you call the semaphore_pend, and in the button callback.
  • There is no errors when the code running before semaphore_pend or button callback, but there are some errors in the main before start debug.

    I'm using CC1310F32 instead CC1310F128:

    Error: Problem scanning pend Queue: JavaException: java.lang.Exception: Target memory read failed at address: 0xbebebebe, length: 8This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.

    Error: Problem fetching Task stack: Error: fetchArray called with length 0.

  • like the first message says, the application is either uninitialized or corrupt. Before you create the task and semaphore, you will get an error.
    If you start the application and pause it with the debugger, the ROV messages should disappear.
    Can you confirm this?

    Are you using events in your code? I've seen this message before "blocked by unknown" when using events. Just to be clear, your code doesn't work anymore after a few minutes? Or does still work but you see "blocked by unknown"?
  • Hi Michel,
    when i start the application and pause, the ROV messages disappear.

    I'm not using events in my code.

    When the application is running for some minutes, the task is "blocked by unknown" instead "blocked on Semaphore: 0x200012a0" and i can't restart the task.
  • Hi Jose,
    I am not too familiar with the CCS TI-RTOS environment since I've worked only with IAR but here are a few things that I've found that helped figure out the problem.
    The fact that it occurs only after some time makes it look like it was some data overflowing.

    If you look at the Task view in ROV, can you see all your tasks (or do some names disappear)? Check just after all tasks have been created, to see how much of the stack has been used for each task (any tasks close to their limit?). Then check after the program stops working, have any names disappeared? Does the data still make sense? If not, most likely, you have a stack overflow and try increasing the stack sizes.

    Another thing, once the program stops working, can you check what semTxHandle is pointing to? Is it still 0x200012a0? If not, it could mean that you have some free pointer changing variables in areas where it shouldn't.

    Give these a try and let us know what you come up with.
    Michel
  • Hi Michel,

      thanks for your comments but i did some changes and not solve my problem.

      First, I'm using CCS but i tested you said and the semTxHandle is pointing to 0x200012a0 everytime, when crashing too.

     

       Attach my code, i dont know if there is a rtos bug:

    /* XDCtools Header files */
    #include <stdlib.h>
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #include "smartrf_settings/smartrf_settings.h"
    
    /* Pin driver handles */
    static PIN_Handle buttonPinHandle;
    static PIN_Handle ledPinHandle;
    
    
    /* Global memory storage for a PIN_Config table */
    static PIN_State buttonPinState;
    static PIN_State ledPinState;
    
    
    
    /***** Defines *****/
    
    /* TX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 8  /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             30 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                       * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                       * Max 30 payload bytes
                                       * 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */
    
    
    /***** Defines *****/
    #define TX_TASK_STACK_SIZE 1024
    #define TX_TASK_PRIORITY   2
    
    /* TX Configuration */
    #define PAYLOAD_LENGTH      30
    #define PACKET_INTERVAL     (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */
    
    
    /***** Prototypes *****/
    static void txTaskFunction(UArg arg0, UArg arg1);
    
    
    
    /*
     * Initial LED pin configuration table
     *   - LEDs Board_LED0 is on.
     *   - LEDs Board_LED1 is off.
     */
    PIN_Config ledPinTable[] = {
        Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /*
     * Application button pin configuration table:
     *   - Buttons interrupts are configured to trigger on falling edge.
     */
    PIN_Config buttonPinTable[] = {
        Board_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
        PIN_TERMINATE
    };
    
    /***** Variable declarations *****/
    static Task_Params txTaskParams;
    Task_Struct txTask;    /* not static so you can see in ROV */
    static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
    static uint8_t txPacket[PAYLOAD_LENGTH];
    static uint16_t seqNumber;
    
    Semaphore_Struct semTxStruct;
    Semaphore_Handle semTxHandle;
    
    
    
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /*
     *  ======== buttonCallbackFxn ========
     *  Pin interrupt Callback function board buttons configured in the pinTable.
     *  If Board_LED3 and Board_LED4 are defined, then we'll add them to the PIN
     *  callback function.
     */
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
        uint32_t currVal = 0;
    
        /* Debounce logic, only toggle if the button is still pushed (low) */
        CPUdelay(8000*50);
        if (!PIN_getInputValue(pinId)) {
            /* Toggle LED based on the button pressed */
            switch (pinId) {
                case Board_BUTTON0:
                    currVal =  PIN_getOutputValue(Board_LED0);
                    PIN_setOutputValue(ledPinHandle, Board_LED0, !currVal);
                    Semaphore_post(semTxHandle);
                    break;
    
                default:
                    /* Do nothing */
                    break;
            }
        }
    }
    
    /*
    */
    /***** Function definitions *****/
    void TxTask_init()
    {
        Task_Params_init(&txTaskParams);
        txTaskParams.stackSize = TX_TASK_STACK_SIZE;
        txTaskParams.priority = TX_TASK_PRIORITY;
        txTaskParams.stack = &txTaskStack;
        txTaskParams.arg0 = (UInt)1000000;
    
        Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
    }
    
    static void txTaskFunction(UArg arg0, UArg arg1)
    {
        uint32_t time;
        uint32_t currVal = 0;
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
        RF_cmdPropTx.pPkt = txPacket;
        RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
        RF_cmdPropTx.startTrigger.pastTrig = 1;
        RF_cmdPropTx.startTime = 0;
    
        if (!rfHandle) {
        	/* Request access to the radio */
        	rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        	/* Set the frequency */
        	RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
        }
    
        /* Get current time */
        //System_printf("Hello World!\n");
    
        time = RF_getCurrentTime();
        while(1)
        {
            Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);
    
            /* Create packet with incrementing sequence number and random payload */
        	txPacket[0] = (uint8_t)(seqNumber >> 8);
        	txPacket[1] = (uint8_t)(seqNumber++);
        	txPacket[2] = 0x01;
        	txPacket[3] = 0x01;
        	txPacket[4] = 0x00;
            uint8_t i;
            for (i = 5; i < PAYLOAD_LENGTH; i++)
            {
            	txPacket[i] = rand();
            }
    
            /* Set absolute TX time to utilize automatic power management */
            time += PACKET_INTERVAL;
            RF_cmdPropTx.startTime = time;
    
            /* Send packet */
            RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
            if (!(result & RF_EventLastCmdDone))
            {
                /* Error */
                while(1);
            }
    
            currVal =  PIN_getOutputValue(Board_LED1);
            PIN_setOutputValue(ledPinHandle, Board_LED1, !currVal);
    
    
        }
    }
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
    
        Semaphore_Params semParams;
    
        /* Call board init functions */
        Board_initGeneral();
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, ledPinTable);
        if(!ledPinHandle) {
            System_abort("Error initializing board LED pins\n");
        }
    
        buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
        if(!buttonPinHandle) {
            System_abort("Error initializing button pins\n");
        }
    
        /* Setup callback for button pins */
        if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
            System_abort("Error registering button callback function");
        }
    
    	/* Construct a Semaphore object to be used as a resource lock, inital count 0 */
    	Semaphore_Params_init(&semParams);
    	Semaphore_construct(&semTxStruct, 0, &semParams);
    
    
    	/* Obtain instance handle */
    	semTxHandle = Semaphore_handle(&semTxStruct);
    
        /* Initialize task */
        TxTask_init();
    
        /* Start kernel. */
        BIOS_start();
    
        return (0);
    }
    

  • Hi Jose,

    Any update on this?

    Todd
  • Hi Jose,
    Could put your code in a text file because it does not show up on the forum?
    Could you also put sreen captures of the Task ROV (The module tab and detailed tab if possible) when the crash has occurred?
    Michel
  • Hi Michel,

       attach the code. If you have any DK or the Launchpad you can compile it and see that work for some minutes, but then the main task and interrupt run but the secondary task and semaphore do not run.

    Thanks!

    pinInterrupt - copia.c
    /*
     * Copyright (c) 2015-2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== pinInterrupt.c ========
     */
    
    /* XDCtools Header files */
    #include <stdlib.h>
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #include "smartrf_settings/smartrf_settings.h"
    
    /* Pin driver handles */
    static PIN_Handle buttonPinHandle;
    static PIN_Handle ledPinHandle;
    
    
    /* Global memory storage for a PIN_Config table */
    static PIN_State buttonPinState;
    static PIN_State ledPinState;
    
    
    
    /***** Defines *****/
    
    /* TX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 8  /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             30 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                       * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                       * Max 30 payload bytes
                                       * 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */
    
    
    /***** Defines *****/
    #define TX_TASK_STACK_SIZE 1024
    #define TX_TASK_PRIORITY   2
    
    /* TX Configuration */
    #define PAYLOAD_LENGTH      30
    #define PACKET_INTERVAL     (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */
    
    
    /***** Prototypes *****/
    static void txTaskFunction(UArg arg0, UArg arg1);
    
    
    
    /*
     * Initial LED pin configuration table
     *   - LEDs Board_LED0 is on.
     *   - LEDs Board_LED1 is off.
     */
    PIN_Config ledPinTable[] = {
        Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /*
     * Application button pin configuration table:
     *   - Buttons interrupts are configured to trigger on falling edge.
     */
    PIN_Config buttonPinTable[] = {
        Board_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
        PIN_TERMINATE
    };
    
    /***** Variable declarations *****/
    static Task_Params txTaskParams;
    Task_Struct txTask;    /* not static so you can see in ROV */
    static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
    static uint8_t txPacket[PAYLOAD_LENGTH];
    static uint16_t seqNumber;
    static PIN_Handle pinHandle;
    
    Semaphore_Struct semTxStruct;
    Semaphore_Handle semTxHandle;
    
    
    
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /*
     *  ======== buttonCallbackFxn ========
     *  Pin interrupt Callback function board buttons configured in the pinTable.
     *  If Board_LED3 and Board_LED4 are defined, then we'll add them to the PIN
     *  callback function.
     */
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
        uint32_t currVal = 0;
    
        /* Debounce logic, only toggle if the button is still pushed (low) */
        CPUdelay(8000*50);
        if (!PIN_getInputValue(pinId)) {
            /* Toggle LED based on the button pressed */
            switch (pinId) {
                case Board_BUTTON0:
                    currVal =  PIN_getOutputValue(Board_LED0);
                    PIN_setOutputValue(ledPinHandle, Board_LED0, !currVal);
                    Semaphore_post(semTxHandle);
                    break;
    
                default:
                    /* Do nothing */
                    break;
            }
        }
    }
    
    /*
    */
    /***** Function definitions *****/
    void TxTask_init()
    {
        Task_Params_init(&txTaskParams);
        txTaskParams.stackSize = TX_TASK_STACK_SIZE;
        txTaskParams.priority = TX_TASK_PRIORITY;
        txTaskParams.stack = &txTaskStack;
        txTaskParams.arg0 = (UInt)1000000;
    
        Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
    }
    
    static void txTaskFunction(UArg arg0, UArg arg1)
    {
        uint32_t time;
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
        RF_cmdPropTx.pPkt = txPacket;
        RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
        RF_cmdPropTx.startTrigger.pastTrig = 1;
        RF_cmdPropTx.startTime = 0;
    
        if (!rfHandle) {
        	/* Request access to the radio */
        	rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        	/* Set the frequency */
        	RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
        }
    
        /* Get current time */
        System_printf("Hello World!\n");
    
        time = RF_getCurrentTime();
        while(1)
        {
            Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);
    
            /* Create packet with incrementing sequence number and random payload */
        	txPacket[0] = (uint8_t)(seqNumber >> 8);
        	txPacket[1] = (uint8_t)(seqNumber++);
        	txPacket[2] = 0x01;//
        	txPacket[3] = 0x01;//
        	txPacket[4] = 0x00;//
            uint8_t i;
            for (i = 5; i < PAYLOAD_LENGTH; i++)
            {
            	txPacket[i] = rand();
            }
    
            /* Set absolute TX time to utilize automatic power management */
            time += PACKET_INTERVAL;
            RF_cmdPropTx.startTime = time;
    
            /* Send packet */
            RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
            if (!(result & RF_EventLastCmdDone))
            {
                /* Error */
                while(1);
            }
    
            PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
    
    
        }
    }
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
    
        Semaphore_Params semParams;
    
        /* Call board init functions */
        Board_initGeneral();
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, ledPinTable);
        if(!ledPinHandle) {
            System_abort("Error initializing board LED pins\n");
        }
    
        buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
        if(!buttonPinHandle) {
            System_abort("Error initializing button pins\n");
        }
    
        /* Setup callback for button pins */
        if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
            System_abort("Error registering button callback function");
        }
    
    	/* Construct a Semaphore object to be used as a resource lock, inital count 0 */
    	Semaphore_Params_init(&semParams);
    	Semaphore_construct(&semTxStruct, 0, &semParams);
    
    
    	/* Obtain instance handle */
    	semTxHandle = Semaphore_handle(&semTxStruct);
    
        /* Initialize task */
        TxTask_init();
    
        /* Start kernel. */
        BIOS_start();
    
        return (0);
    }
    

  • Hi Jose,

    I don't have a Launchpad or DK.

    I looked through your code and I see a potential problem:

    You use the CPUdelay function inside your button callback. You ISR function should be executed as quickly as possible without any delays.

    There are two ways of doing this:

    1. Handle your debounce in your task.
      1. Use semaphore post as soon as you enter the Button callback function.
      2. Do your debouncing in your task (I would replace the CPUdelay function with Task_sleep. I don't know whether CPUdelay is safe to use inside a task)
    2. Use a clock and do your debouncing (get pin and semaphore post) in the clock callback function

    Try one of the two methods and let us know if it works.

    Michel

  • Hi Michel,

       thanks for your comments. I did your first way (the second i dont like), remove CPUDelay from button callback and use Task_sleep inside the task but not solve the problem.

      Some minutes later the program is running, the task turn to "blocked" by unknown. Attach the picture. I think that the RTOS turn the uC to sleep or similar and the semaphore pointer lost...

  • Jose,

    First, I'd make the debounce semaphore binary instead of counting (semParams.mode = Semaphore_Mode_BINARY). You don't need a counting semaphore in this case.

    Second can you look at the call stack for the txTaskFunction? It's in ROV->Task->CallStacks. I'm wondering if you are blocking in the RF_runCmd function. You get blockedOn = "Unknown" in ROV if the the task is in Blocked mode and the item the task is blocking on not a Mailbox, GateMutex, GateMutexPri, Semaphore, Event or Task_sleep.

    Todd

  • Hi Todd,

       thanks for your advice. I found the problem. Blocked by "unknown" is RF_runCmd function.

       If i remove this code of the task function, not blocked by unknown:

    /* Send packet */
    /*
    RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
    if (!(result & RF_EventLastCmdDone))
    {
    //Error
    System_printf("Error RF_runCmd\n");
    //while(1);
    }
    */

    What can i do to send a  RF packet inside the task?

  • I moved your thread to the device forum. They can give you details about the RF module.

    Todd
  • Hi,

       finally i solved this problem doing RF_open and RF_close in the loop every time before sending Semaphore_post(). Also I have to set rfHandle to NULL because the RF_close do not reset this like i hope.

    Thanks!

  • Hi Jose and TI team., 

    I have same issue as you mentioned above, but i couldnt solve my problem as you said. Could you please explain more clearly what you did to solve this issue. 

    I can send RF packets as well but after short time, when i send again using with RF_runCmd, the package is send to the receiver, but the RF_runCmd not return as expected. It is halting and I see the Unknown message at Blockon in the ROV.

    I have checked the same command on the EasyLink api, but it is the same as we did.

    Thanks.

    TI-RTOS 2.20.00.06