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] [SYS/BIOS] why I cant use GPIO peripheral interrupt enter a HWI thread?

Other Parts Discussed in Thread: SYSBIOS

XDCtools version: 3.31.1.33

RTOS version: 2.12.1.33

IDE: CCS6.1.0 on win7 64bits

Emulator: XDS100V3

Device: F28M35 self-designed board

problem I met:program trouble hult at 

I wonder what the cause.

MY CODE:

/*
* ======== main.c ========
*/
//The Event ID is what muxes that interrupt to your specific GPIO peripheral.
#include <xdc/std.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Hwi.h>

#include "DSP28x_Project.h"
Int c=0;
/*
* ======== taskFxn ========
*/
Void taskFxn(UArg a0, UArg a1)
{
System_printf("enter taskFxn()\n");

Task_sleep(10);

System_printf("exit taskFxn()\n");

System_flush(); /* force SysMin output to console */
}
/* Runs when interrupt occurs */
Void myIsr16(UArg arg)
{
c++;
}
/*
* ======== main ========
*/
Int main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
//PieVectTable.XINT1 = &xint1_isr;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
IER |= M_INT1; // Enable CPU INT1
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
EALLOW;
GpioG1CtrlRegs.GPBMUX2.bit.GPIO54 = 0; // GPIO
GpioG1CtrlRegs.GPBDIR.bit.GPIO54 = 0; // input
GpioG1CtrlRegs.GPBQSEL2.bit.GPIO54 = 2; // XINT2 Qual using 6 samples
GpioG1CtrlRegs.GPBCTRL.bit.QUALPRD2 = 0xFF; // Each sampling window is
// 510*SYSCLKOUT
GpioG1TripRegs.GPTRIP4SEL.bit.GPTRIP4SEL = 54; //Map Trip Input 5(XINT2) to
EDIS;
XIntruptRegs.XINT1CR.bit.POLARITY = 0; // Falling edge interrupt
XIntruptRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

Task_Handle task;
Error_Block eb1;

System_printf("Enter main()\n");

Error_init(&eb1);
task = Task_create(taskFxn, NULL, &eb1);
if (task == NULL)
{
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}


Hwi_Params hwiParams;
Hwi_Handle myHwi;
Error_Block eb2;
/* Initialize error block and hwiParams to default values */
Error_init(&eb2);
Hwi_Params_init(&hwiParams);
/* Set myIsr16 parameters */
hwiParams.arg = 0;
hwiParams.enableInt = TRUE;

/* Create a Hwi object for interrupt number 6
* that invokes myIsr16() with argument 12 */
myHwi = Hwi_create(32, myIsr16, &hwiParams, &eb2);
if (myHwi == NULL)
{
System_abort("Hwi create failed");
}
/* enable both interrupts */
Hwi_enableInterrupt(32);


System_printf("Bios will start here!\n");
System_flush();
BIOS_start(); /* does not return */
return(0);
}

And CFG:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');

var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');

/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/

/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
Defaults.common$.namedModule = false;
*/

/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;

/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/

/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
Text.isLoaded = false;
*/

/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
*/

/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize = 0x800;

/*
* Build a custom SYS/BIOS library from sources.
*/
BIOS.libType = BIOS.LibType_Custom;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x1000;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;

/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 32;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;

Thanks for your help!

  • The SYS/BIOS Hwi module internally manages the configuration of the PIE as well as setting up IER, IFR, etc.
    Additionally, SYS/BIOS carefully orchestrates when interrupts are enabled.
    You MUST not enable interrupts in main().
    You should remove this code from main():
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EALLOW; // This is needed to write to EALLOW protected registers
    //PieVectTable.XINT1 = &xint1_isr;
    EDIS;
    PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
    IER |= M_INT1; // Enable CPU INT1
    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
    EALLOW;

    and this:

    EINT; // Enable Global interrupt INTM
    ERTM; // Enable Global realtime interrupt DBGM

    Where is "INT14_ISR(void)" defined?

    Alan
  • Hi Alan
    With your help my program will not stop at INT14 anymore and actually I dont use any cputimers.
    But I still has some problem.
    In a program without OS. I configure the interrupt alike and it can enter interrupt correctly. But now I can only set the IER and the HWI thread seem not be reached.
    I modified my code with your suggestion.
    Do you have any idea?
    Hope for your kind reply!

    Int main()
    {
    InitSysCtrl();

    GpioG1CtrlRegs.GPBMUX2.bit.GPIO54 = 0; // GPIO
    GpioG1CtrlRegs.GPBDIR.bit.GPIO54 = 0; // input
    GpioG1CtrlRegs.GPBQSEL2.bit.GPIO54 = 2; // XINT1 Qual using 6 samples
    GpioG1CtrlRegs.GPBCTRL.bit.QUALPRD2 = 0xFF; // Each sampling window is
    // 510*SYSCLKOUT
    GpioG1TripRegs.GPTRIP4SEL.bit.GPTRIP4SEL = 54; //Map Trip Input to XINT1
    EDIS;
    XIntruptRegs.XINT1CR.bit.POLARITY = 0; // Falling edge interrupt
    XIntruptRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
    Hwi_Params hwiParams;
    Hwi_Handle myHwi;
    Error_Block eb2;
    /* Initialize error block and hwiParams to default values */
    Error_init(&eb2);
    Hwi_Params_init(&hwiParams);
    /* Set myIsr parameters */
    hwiParams.arg = 0;
    hwiParams.enableInt = FALSE;

    /* Create a Hwi object for interrupt number 35*/
    myHwi = Hwi_create(35, myIsr, &hwiParams, &eb2);
    if (myHwi == NULL)
    {
    System_abort("Hwi create failed");
    }
    /* enable both interrupts */
    Hwi_enableInterrupt(35);//set PIEIER1 to 0000000000001000

    System_printf("Bios will start here!\n");
    System_flush();
    BIOS_start(); /* does not return */
    return(0);
    }
  • Here I give you my full project

    7103.PIE_HWI_Test.zip

  • Thanks! I finally solve it with your help! Ignore the two posts I posted later~