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.

Hwi exception when SysTickIntHandler happens

Other Parts Discussed in Thread: SYSBIOS

I am new to TI-RTOS and the application that I want to create is to get a A/D reading every 3 uSecs I was thinking of using the sysTickIntHandler to call a function that start ADC. So as a starting point I created some code that is suppose to call the the system interrupt handler every 3 uSecs but the code gets the following exception when it runs. My stack size is = 4096 and heap = 512. Does the RTOS not support this interrupt does it need to be done using a task?

Start ADC InterruptClk count 0

ti.sysbios.family.arm.m3.Hwi: line 1120: E_noIsr: id = 15, pc = 00005858

Exception occurred in background thread at PC = 0x00005858.

Core 0: Exception occurred in ThreadType_Task.

Task name: ti.sysbios.knl.Task.IdleTask, handle: 0x200045a8.

Task stack base: 0x20001360.

Task stack size: 0x800.

R0 = 0x00000090 R8 = 0xffffffff

R1 = 0x200040ac R9 = 0xffffffff

R2 = 0x00000089 R10 = 0xffffffff

R3 = 0x00000004 R11 = 0xffffffff

R4 = 0x0000b97c R12 = 0x00000020

R5 = 0x0000b97c SP(R13) = 0x20001b10

R6 = 0x00000001 LR(R14) = 0x0000581d

R7 = 0x0000b970 PC(R15) = 0x00005858

PSR = 0x01000000

ICSR = 0x0042380f

MMFSR = 0x00

BFSR = 0x00

UFSR = 0x0000

HFSR = 0x00000000

DFSR = 0x0000000b

MMAR = 0xe000ed34

BFAR = 0xe000ed38

AFSR = 0x00000000

Terminating execution...

 

My Code

#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
// #include <ti/drivers/I2C.h>
// #include <ti/drivers/SDSPI.h>
// #include <ti/drivers/SPI.h>
// #include <ti/drivers/UART.h>
// #include <ti/drivers/USBMSCHFatFs.h>
// #include <ti/drivers/Watchdog.h>
// #include <ti/drivers/WiFi.h>
#include <driverlib/rom_map.h>
#include <driverlib/sysctl.h>
#include <driverlib/systick.h>
/* Example/Board Header files */
#include "Board.h"


static volatile uint32_t g_ui32TickCount;
uint32_t g_ui32LastTick = 0;

//*****************************************************************************
//
// Handles the SysTick timeout interrupt.
//
//*****************************************************************************
void
SysTickIntHandler(void)
{
    //
    // Increment the tick count.
    //
    g_ui32TickCount++;
}

void taskUpdateStatus(UArg a0, UArg a1)
{
 while(1)
 {
    System_printf("Clk count %d \n", g_ui32TickCount);
    System_flush();
    Task_sleep(300);
 }

}
/*
 *  ======== main ========
 */
Int main(Void)
{
 Task_Handle task0;
 uint32_t ui32SysClock;
    Error_Block eb;

    /* Call board init functions. */
    Board_initGeneral();
    Board_initGPIO();
    // Board_initDMA();
    // Board_initI2C();
    // Board_initSDSPI();
    // Board_initSPI();
    // Board_initUART();
    // Board_initUSB(Board_USBDEVICE);
    // Board_initUSBMSCHFatFs();
    // Board_initWatchdog();
    // Board_initWiFi();
    Error_init(&eb);
    /* Turn on user LED */
    GPIO_write(Board_LED, Board_LED_ON);

    //
    // Set the clocking to run at 1 MHz.
    //
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_XTAL_1MHZ |
                        SYSCTL_OSC_MAIN);
    ui32SysClock = MAP_SysCtlClockGet();

    //
    // Configure SysTick to periodically interrupt once every 3uSec
    //
    g_ui32TickCount = 0;
    SysTickPeriodSet(ui32SysClock / 3);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();

    task0 = Task_create(taskUpdateStatus, NULL, &eb);
     if(task0 == NULL)
       System_abort("Task create failed");


    System_printf("Start ADC Interrupt");
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

  • Hi Teresa,

    TI-RTOS kernel (formerly known as SYS/BIOS) has its own nvic (interrupt controller) driver in the Hwi module. From the code you shared it looks like you are trying to modify the nvic registers (MAP_SysTickIntEnable() call) which basically conflicts with the kernel as the kernel is suppose to be managing the nvic.

    I believe what is happening is that the kernel installs a vector table with no entry for Interrupt 15 as it does not know you have a handler for it and your code enables interrupt 15. Therefore, when interrupt 15 gets generated, the kernel determines interrupt 15 to be a spurious interrupt and raises an error.

    To fix this, what you need to do is use the kernel's Timer module to register a SysTick interrupt handler. Here's a link to the SysTick Timer module cdoc:

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/sysbios/6_35_04_50/exports/bios_6_35_04_50/docs/cdoc/index.html#ti/sysbios/family/arm/m3/Timer.html

    And some example *.c + *.cfg code showing how to create a timer instance for this module:

    *.cfg:

    var Timer = xdc.useModule('ti.sysbios.family.arm.m3.Timer');

    *.c:

    #include <ti/sysbios/family/arm/m3/Timer.h>

    Int main ()

    {

        ....

        Timer_Params prms;

        Timer_Params_init(&prms);

        prms.period = 3;

        prms.periodType = Timer_PeriodType_MICROSECS; // period is in microsecs

        prms.startMode = Timer_StartMode_AUTO; // Timer is started by BIOS_start()

        prms.runMode = Timer_RunMode_CONTINUOUS;

        Timer_create(-1, myIsr, &prms, NULL);

        ...

        BIOS_start();

    }

    Best,

    Ashish

  • Thanks Ashish - I am new to TI-RTOS and CCS so one of the major problems I am having is that all the examples that came with the TIVA eval board do not use the RTOS so I have been looking at those examples and trying to use them with the RTOS and have been causing myself twice as much work. For example I was trying to do this same thing with the USB stick and when I posted on this site found out about USB driver USBMSCHFatFs - Wow did that make reading and writing to a USB stick easy.I learned about the TI Resouce center when I posted about the USB which allowed me to find more RTOS examples but still not enough examples. Is there more RTOS examples on the TI site?  The really frustrating thing is that when you go to C:\ti\tirtos_1_10_00_23\products\TivaWare_C_Series-1.0\examples you expect to see some RTOS examples unti the tirtos directory and from what I can tell they are not. What do people recommend for newbies to read - I have read the getting started but no mention in there about some the drivers that are available and how to use them examples.

     

  • Hi Teresa,

    As far as I know the only TI-RTOS examples available are the ones in TI Resource explorer in CCS. I can check with the TI-RTOS team if there are more examples available through some training wiki page. From your post it looks like you want an example for certain supported drivers but could not find any. Can you tell me which driver you are interested in and I can try to find an example and share it ?

    Best,

    Ashish

  • Hi Ashish,

    That link you posted has been exactly what I have been looking for! I have gone through the getting started and the sys/bios users guide and have not seen any mention of that web link. It has all the information that a programmer needs to work with the RTOS in an easy to access manner. I was a little concerned that it looks like the link sends me to DSP documentation. You should pass on to the TI-RTOS team that they need to make that link available in the getting started and clearly highlight this is documents all the features available with the RTOS. I feel like I have spent the last 4 weeks stumbling around in a dark room and you just gave me the flashlight. It is terrible that the examples under the ti/tirtos are not RTOS examples. The ones that are in the TI Resource should be put in the examples directory. It seems like TI has tons of information out there on how things work but you need a secert decoder ring to find the ones that are golden.

    Teresa