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/EK-TM4C123GXL: ti.sysbios.family.arm.m3.Hwi exception

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello all,

I have juste started develloping on TivaC123GXL with ti RTOS and I have problem that I hope you have a solution.

I created a task that write on i2c slave and it works fine, after that i created a GPIO interruption on PF4 in order to tell the task to write on i2c slave when the interrupt occure, then I had this message in the CCS console :

waiting for i2c interruption ..
waiting for i2c interruption ..
waiting for i2c interruption ..
waiting for i2c interruption ..
will send
ti.sysbios.family.arm.m3.Hwi: line 1277: E_noIsr: id = 85, pc = 00005a44
Exception occurred in background thread at PC = 0x00005a44.
Core 0: Exception occurred in ThreadType_Task.
Task name: {unknown-instance-name}, handle: 0x20001a10.
Task stack base: 0x20000360.
Task stack size: 0x800.
R0 = 0x00000000 R8 = 0x00000001
R1 = 0x00006d79 R9 = 0x00000008
R2 = 0x20000ab4 R10 = 0x00000008
R3 = 0x00000001 R11 = 0x20001eb0
R4 = 0x20001d60 R12 = 0x00000000
R5 = 0x000000f8 SP(R13) = 0x20000a70
R6 = 0x00000000 LR(R14) = 0x00005a95
R7 = 0x20000ab4 PC(R15) = 0x00005a44
PSR = 0x61000000
ICSR = 0x00423855
MMFSR = 0x00
BFSR = 0x00
UFSR = 0x0000
HFSR = 0x00000000
DFSR = 0x0000000b
MMAR = 0xe000ed34
BFAR = 0xe000ed38
AFSR = 0x00000000
Terminating execution...

the task is waiting for the interrupt, when I occure the interrupt by pushing the user button linked to PF4 the message above occure.

When I tested the interrupt alone by commenting the task, it work fine.

So as conclusion : task alone works fine, interrupt alone works fine but when I use the task and the interrupt i have the message above :

Here is my code :

/*
* Copyright (c) 2015, 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.
*/

/*
* ======== empty_min.c ========
*/
/* XDCtools Header files */
#include <stdbool.h>
#include <xdc/std.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>

/* Board Header file */
#include "Board.h"
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <stdio.h>

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"

#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include <ti/drivers/I2C.h>

#define MY_TASK2_STACK_SIZE 2048

Task_Struct myTask2;
Task_Params myTask2Params;
Char myTask2Stack[MY_TASK2_STACK_SIZE];
int is = 0;

void DRI_vidExtractTouchInfos(void)
{

uint8_t writeBuffer[3];
I2C_Handle handle;
I2C_Params i2cparams;
I2C_Transaction i2c;

I2C_Params_init(&i2cparams);
i2cparams.bitRate = I2C_100kHz;
handle = I2C_open(EK_TM4C123GXL_I2C3, &i2cparams);
if (handle == NULL) {
System_abort("I2C was not opened");

}

while(1)
{
printf("waiting for i2c interruption .. \n");
if(is == 1)
{
i2c.slaveAddress = Board_TPL0401_ADDR;
i2c.readCount = 0;
i2c.readBuf = NULL;
i2c.writeBuf = writeBuffer;

/* Enable the PWM oscillator */
writeBuffer[0] = 0x00;
writeBuffer[1] = 0x81;
i2c.writeCount = 2;
printf("will send \n");
if (!I2C_transfer(handle, &i2c)) {
GPIO_write(Board_LED1, Board_LED_ON);
System_abort("Bad I2C transfer! here");

}

/* Bring the LEDs into PWM mode */
writeBuffer[0] = 0x8C;
writeBuffer[1] = 0xAA;
writeBuffer[2] = 0xAA;
i2c.writeCount = 3;
if (!I2C_transfer(handle, &i2c)) {
GPIO_write(Board_LED1, Board_LED_ON);
System_abort("Bad I2C transfer!");
}

is =0;
}
Task_sleep(100);
}


}

void gpioButtonFxn0(void)
{
/* Clear the GPIO interrupt and toggle an LED */

GPIO_toggle(Board_LED0);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
is = 1;

}
int main(void)
{


Board_initGeneral();
Board_initGPIO();
Board_initI2C();

//Set the clock to 80Mhz
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlDelay(5);

GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);

GPIOIntRegister(GPIO_PORTF_BASE,gpioButtonFxn0);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);

/* this task wait for touch panel event */
Task_Params_init(&myTask2Params);
myTask2Params.stackSize = MY_TASK2_STACK_SIZE;
myTask2Params.stack = &myTask2Stack;
myTask2Params.priority = 3;
Task_construct(&myTask2, (Task_FuncPtr)DRI_vidExtractTouchInfos, &myTask2Params, NULL);

/* Start BIOS */


BIOS_start();


return (0);
}

and here is my memory section configuration :

MEMORY
{
FLASH (RX) : origin = 0x00000000, length = 0x00040000
SRAM (RWX) : origin = 0x20000000, length = 0x00008000
}

/* Section allocation in memory */

SECTIONS
{
.text : > FLASH
.const : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH

.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM
.vtable : > SRAM

}

Thank you very much for help

Best regards, 

  • Hi,
    I think you want to use the semaphore on this. In your Hwi gpioButtonFxn0, you will call the semaphore_post() while in the while (1) inside the DRI_vidExtractTouchInfos you will call the semaphore_pend(). After the semaphore_pend() is called, the task will not execute further unless it receives a semaphore handle from the gpioButtonFxn0.

    For details about the semaphore usage please go to chapter 8 in the below user's guide.
    training.ti.com/.../TI_RTOS_Kernel_Workshop_Student_Guide_rev4.00.pdf

    One line TI-RTOS training can be found in this web page.
    training.ti.com/ti-rtos-workshop-series-1-10-welcome
  • Hello Charles,

    Thank you for your response.

    I have used a semaphore but i still have the same problem.

    Here is my new code :


    /*
    * Copyright (c) 2015, 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.
    */

    /*
    * ======== empty_min.c ========
    */
    /* XDCtools Header files */
    #include <stdbool.h>
    #include <xdc/std.h>
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>





    /* Board Header file */
    #include "Board.h"
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <stdio.h>

    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"

    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/interrupt.h"
    #include <ti/drivers/I2C.h>
    #include <ti/sysbios/knl/Semaphore.h>



    Error_Block eb;


    Semaphore_Handle sem;

    #define MY_TASK2_STACK_SIZE 2048

    Task_Struct myTask2;
    Task_Params myTask2Params;
    uint8_t myTask2Stack[MY_TASK2_STACK_SIZE];
    int is = 0;

    void DRI_vidExtractTouchInfos(void)
    {


    uint8_t writeBuffer[3];
    I2C_Handle handle;
    I2C_Params i2cparams;
    I2C_Transaction i2c;

    I2C_Params_init(&i2cparams);
    i2cparams.bitRate = I2C_100kHz;
    handle = I2C_open(EK_TM4C123GXL_I2C3, &i2cparams);
    if (handle == NULL) {
    System_abort("I2C was not opened");

    }

    while(1)
    {
    printf("waiting for i2c interruption .. \n");
    Semaphore_pend(sem, BIOS_WAIT_FOREVER);
    //if(is == 1)
    {

    //printf("writing i2c \n");
    i2c.slaveAddress = Board_TPL0401_ADDR;
    i2c.readCount = 0;
    i2c.readBuf = NULL;
    i2c.writeBuf = writeBuffer;

    /* Enable the PWM oscillator */
    writeBuffer[0] = 0x00;
    writeBuffer[1] = 0x81;
    i2c.writeCount = 2;
    printf("will send \n");
    if (!I2C_transfer(handle, &i2c)) {
    GPIO_write(Board_LED1, Board_LED_ON);
    System_abort("Bad I2C transfer! here");

    }
    ////
    //// /* Bring the LEDs into PWM mode */
    //// writeBuffer[0] = 0x8C;
    //// writeBuffer[1] = 0xAA;
    //// writeBuffer[2] = 0xAA;
    //// i2c.writeCount = 3;
    //// if (!I2C_transfer(handle, &i2c)) {
    //// GPIO_write(Board_LED1, Board_LED_ON);
    //// System_abort("Bad I2C transfer!");
    //// }
    ////
    is =0;
    }
    Task_sleep(100);
    }






    }



    void gpioButtonFxn0(void)
    {
    /* Clear the GPIO interrupt and toggle an LED */

    //GPIO_toggle(Board_LED0);

    // is = 1;
    Semaphore_post(sem);
    GPIOIntClear(GPIO_PORTF_BASE, GPIO_INT_PIN_4);

    }
    int main(void)
    {

    Error_init(&eb);

    sem = Semaphore_create(0, NULL, &eb);
    if (sem == NULL) {
    System_abort("Semaphore create failed");
    }

    Board_initGeneral();
    Board_initGPIO();
    Board_initI2C();

    //Set the clock to 80Mhz
    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlDelay(5);

    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

    GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);

    GPIOIntRegister(GPIO_PORTF_BASE,gpioButtonFxn0);
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);



    /* this task wait for touch panel event */
    Task_Params_init(&myTask2Params);
    myTask2Params.stackSize = MY_TASK2_STACK_SIZE;
    myTask2Params.stack = myTask2Stack;
    myTask2Params.priority = 3;
    Task_construct(&myTask2, (Task_FuncPtr)DRI_vidExtractTouchInfos, &myTask2Params, NULL);



    /* Start BIOS */


    BIOS_start();




    return (0);
    }





    the same error message, it like a memory corruption or a bad pointer or something like that ....

    waiting for i2c interruption ..
    will send
    ti.sysbios.family.arm.m3.Hwi: line 1277: E_noIsr: id = 85, pc = 00005a00
    Exception occurred in background thread at PC = 0x00005a00.
    Core 0: Exception occurred in ThreadType_Task.
    Task name: {unknown-instance-name}, handle: 0x20001a10.
    Task stack base: 0x20000360.
    Task stack size: 0x800.
    R0 = 0x00000000 R8 = 0x00000001
    R1 = 0x00006d39 R9 = 0x00000008
    R2 = 0x20000ab4 R10 = 0x00000008
    R3 = 0x00000001 R11 = 0x20001e64
    R4 = 0x20001d14 R12 = 0x00000000
    R5 = 0x000000f8 SP(R13) = 0x20000a70
    R6 = 0x00000000 LR(R14) = 0x00005a45
    R7 = 0x20000ab4 PC(R15) = 0x00005a00
    PSR = 0x61000000
    ICSR = 0x00423855
    MMFSR = 0x00
    BFSR = 0x00
    UFSR = 0x0000
    HFSR = 0x00000000
    DFSR = 0x0000000b
    MMAR = 0xe000ed34
    BFAR = 0xe000ed38
    AFSR = 0x00000000
    Terminating execution...



    Best regards,

    Nabil
  • Please do no use printf as it can require a lot of stack size. Try to use System_printf instead. You can also use the ROV to see if you have stack size overflow issue.

    Example as below:

    System_printf("Starting the example\nSystem provider is set to SysMin. "
    "Halt the target to view any SysMin contents in ROV.\n");

    /* SysMin will only print to the console when you call flush or exit */
    System_flush();


    Tips about using printf can be found in this link.
    processors.wiki.ti.com/.../Tips_for_using_printf
  • Thank you Charles for your reactivity,

    I have removed printf before but unfortunately i have always the same problem.

    Regards

    Nabil
  • Hi,

     An HWI exception has occurred which can be due stack overflow, no heap or due to illegal instruction execution (due to a bad pointer).

    I will suggest you increase your runtime stack size and your task stack size as suggested earlier.  

    Also, you can look into ROV for information that can help debug the issue. In ROV, can you check the Hwi, Task and Heap modules? Check the stack/heap sizes, exception trace.

  • Hello again,

    I applied your suggestion.

    here are some screenshot about my task and how in the ROV :

    Still have the same  problem.

    Regards, 

    Nabil,

  • Hi Nabil,

    Please do not use GPIOIntRegister with TI-RTOS. For details, please look at: e2e.ti.com/.../2347913 (specifically the last post of the thread).

    Todd
  • Hello ,

    Thank you for your help, that makes sens.


    Thank you all.

    Regards,

    Nabil