Other Parts Discussed in Thread: SYSBIOS, TMS320C6657
Tool/software: TI-RTOS
Hi,
I have developed a big test application for a custom board. In this environment we will use
an not defined GPIO (0-15) as interrupt external source. In this moment I use evaluation board and
I have developed a TI RTOS task with a little switch placed on test_PH1 connector (GPIO15).
When the ISR works all the other part of system is blocked on Task_sleep function (but I suppose
that all the TI RTOS is on the blocked status). I have used the following TI RTSC libraries:
EDMA3 2.12.2
IPC 3.44.0.00
NDK 2.25.0..9
SYSBIOS 6.46.1.38
PDK 2.0.4
XCDTools 3.32.0.06
CCS TI v8.1.0 (CCS 6.1.3.00034)
The ISR code follows:
******************************** C file:************************
#include <ti/csl/src/intc/csl_intcAux.h>
#include <ti/csl/csl_chip.h>
#include <ti/csl/csl_chipAux.h>
#include <ti/csl/src/intc/csl_intc.h>
#include <ti/csl/csl_gpio.h>
#include <ti/csl/csl_gpioAux.h>
//#define IRQ_SIMUL
typedef struct event2gpio_s
{
uint32_t gpio;
uint32_t eventID;
} event2gpio_t;
volatile int a = 0;
CSL_GpioHandle hGpio = NULL;
const event2gpio_t myGpio2Event[] =
{
{ 0, CSL_GEM_PCIEXPRESS_MSI_INTN_PLUS_2 }, // DO NOT USE
{ 1, CSL_GEM_PCIEXPRESS_MSI_INTN_PLUS_6 }, // DO NOT USE
{ 2, CSL_GEM_GPINT2 },
{ 3, CSL_GEM_GPINT3 },
{ 4, CSL_GEM_GPINT4 },
{ 5, CSL_GEM_GPINT5 },
{ 6, CSL_GEM_GPINT6 },
{ 7, CSL_GEM_GPINT7 },
{ 8, CSL_GEM_GPINT8 },
{ 9, CSL_GEM_GPINT9 },
{ 10, CSL_GEM_GPINT10 },
{ 11, CSL_GEM_GPINT11 },
{ 12, CSL_GEM_GPINT12 },
{ 13, CSL_GEM_GPINT13 },
{ 14, CSL_GEM_GPINT14 },
{ 15, CSL_GEM_GPINT15 }
};
static void GPIO02InterruptHandler(void *arg)
{
/* Clear the event ID. */
CSL_intcEventClear((CSL_IntcEventId)arg);
a++;
}
CSL_IntcContext intcContext;
CSL_IntcEventHandlerRecord EventHandler[30];
CSL_IntcObj intcObj;
CSL_IntcHandle hTest;
CSL_IntcGlobalEnableState state;
CSL_IntcEventHandlerRecord EventRecord;
CSL_IntcParam vectId;
// GPIO irq design base: e2e.ti.com/.../374048
/*******************************************************************************
** Global Function **
*******************************************************************************/
Void mainFPGA(UArg arg0, UArg arg1)
{
int bankNum = 0;
#ifdef IRQ_SIMUL
int cnt = 1000;
int pinNum = FPGA_GPIOIRQ;
#else
int pinNum = 15;
#endif
int aLocal = 0;
DBG_PRINTF("Start %s taskname \"%s\"",
__func__, FPGATASKNAME/*Task_Handle_name(Task_self())*/);
a = 0;
bankNum = 0; // Trigger pinNum in Core0
if (pinNum > SIZEOF(myGpio2Event))
{
DBG_PRINTF("Error: pinNum=%d is too big", pinNum);
return;
}
else if (pinNum < 2)
{
DBG_PRINTF("Error: pinNum=%d is too little", pinNum);
return;
}
/************************************************
*************** INTC Configuration *************
************************************************/
// INTC module initialization
intcContext.eventhandlerRecord = EventHandler;
intcContext.numEvtEntries = 10;
if (CSL_intcInit(&intcContext) != CSL_SOK)
{
DBG_PRINTF("Error: GEM-INTC initialization failed");
return;
}
// Enable NMIs
if (CSL_intcGlobalNmiEnable() != CSL_SOK)
{
DBG_PRINTF("Error: GEM-INTC global NMI enable failed");
return;
}
/* Enable global interrupts */
if (CSL_intcGlobalEnable(&state) != CSL_SOK)
{
DBG_PRINTF("Error: GEM-INTC global enable failed");
return;
}
vectId = CSL_INTC_VECTID_4;
hTest = CSL_intcOpen(&intcObj, myGpio2Event[pinNum].eventID, &vectId , NULL);
if (hTest == NULL)
{
DBG_PRINTF("Error: GEM-INTC Open failed");
return;
}
DBG_PRINTF("Debug: GEM-INTC INT%d EventID%d", hTest->vectId, hTest->eventId);
/* Register an call-back handler which is invoked when the event occurs. */
EventRecord.handler = &GPIO02InterruptHandler;
EventRecord.arg = hTest;
if (CSL_intcPlugEventHandler(hTest, &EventRecord) != CSL_SOK)
{
DBG_PRINTF("Error: GEM-INTC Plug event handler failed");
return;
}
/* Enabling the events. */
if (CSL_intcHwControl(hTest, CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK)
{
DBG_PRINTF("Error: GEM-INTC CSL_INTC_CMD_EVTENABLE command failed");
return;
}
DBG_PRINTF("Debug: GEM-INTC Configuration Completed");
// Open the CSL GPIO Module 0
hGpio = CSL_GPIO_open(0);
#ifdef IRQ_SIMUL
// Set GPIO pin number pinNum as an output pin
CSL_GPIO_setPinDirOutput(hGpio, pinNum);
#endif
#ifdef RISING
#ifdef IRQ_SIMUL
CSL_GPIO_clearOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=0
#endif
// Set interrupt detection on GPIO pin pinNum to rising edge
CSL_GPIO_setRisingEdgeDetect(hGpio, pinNum);
#else
#ifdef IRQ_SIMUL
CSL_GPIO_setOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=1
#endif
// Set interrupt detection on GPIO pin pinNum to rising edge
CSL_GPIO_setFallingEdgeDetect(hGpio, pinNum);
#endif
// Set GPIO pin number pinNum as an input pin
CSL_GPIO_setPinDirInput(hGpio, pinNum); //set FPGA_GPIOIRQ to be input
// Enable GPIO per bank interrupt for bank zero
CSL_GPIO_bankInterruptEnable(hGpio, bankNum);
DBG_PRINTF("Debug: GEM-INTC IRQ waiting");
do
{
#ifdef IRQ_SIMUL
Clock0ISR(/*(UArg) */FPGATASKNAME);
if ((cnt--) == 0)
{
cnt = 100;
CSL_GPIO_setPinDirOutput(hGpio, pinNum);
#ifdef RISING
// Toggle FPGA_GPIOIRQ pin to trigger GPIO interrupt
CSL_GPIO_clearOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=0
CSL_GPIO_setOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=1
#else
// Toggle FPGA_GPIOIRQ pin to trigger GPIO interrupt
CSL_GPIO_setOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=1
CSL_GPIO_clearOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=0
#endif
}
else
{
CSL_GPIO_setPinDirInput(hGpio, pinNum); //set FPGA_GPIOIRQ to be input
// Enable GPIO per bank interrupt for bank zero
// Task_sleep(10);// if uncomment this line also this task remain in blocked status
}
#else
// Task_sleep(10);// if uncomment this line also this task remain in blocked status
#endif
if (a != aLocal) // Wait for entering into ISR
{
#ifdef IRQ_SIMUL
CSL_GPIO_setPinDirOutput(hGpio, pinNum);
#ifdef RISING
CSL_GPIO_clearOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=0
#else
CSL_GPIO_setOutputData(hGpio, pinNum); //FPGA_GPIOIRQ=1
#endif
#endif
DBG_PRINTF("GPIO interrupt occurs a = %d", a);
aLocal = a;
}
} while (global_var->exit_flag == FALSE);
CSL_intcClose(&intcObj);
DBG_PRINTF("Exit %s", __func__);
Task_exit();
return;
}
******************************** CFG file:************************
var Memory = xdc.useModule('xdc.runtime.Memory');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var ti_ndk_config_Emac = xdc.useModule('ti.ndk.config.Emac');
var Icmp = xdc.useModule('ti.ndk.config.Icmp');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var SwTimerPrms = new Timer.Params();
SwTimerPrms.startMode = Timer.StartMode_AUTO;
SwTimerPrms.period = 100000; // 100,000 uSecs = 100ms
SwTimerPrms.instance.name = "SWTimer";
var SwTimer = Timer.create(null, '&swthTimerHandler', SwTimerPrms);
Task.common$.namedInstance = true;
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
Clock.tickPeriod = 750;
var Sem = xdc.useModule('ti.sysbios.knl.Semaphore');
var Diags = xdc.useModule('xdc.runtime.Diags');
var devType = "c6657";
var Csl = xdc.loadPackage('ti.csl');
Csl.Settings.deviceType = devType;
Csl.Settings.useCSLIntcLib = true;
/* Load the OSAL package */
var osType = "tirtos"
var Osal = xdc.useModule('ti.osal.Settings');
Osal.osType = osType;
Osal.socType = devType;
var Qmss = xdc.loadPackage('ti.drv.qmss');
var Emac = xdc.loadPackage('ti.drv.emac');
Emac.Settings.socType = devType;
var Nimu = xdc.loadPackage('ti.transport.ndk.nimu');
Nimu.Settings.socType = devType;
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Exc = xdc.useModule('ti.sysbios.family.c64p.Exception');
Exc.common$.logger = LoggerBuf.create();
Exc.enablePrint = true;
var Global = xdc.useModule('ti.ndk.config.Global');
Global.enableCodeGeneration = false;
var Cache = xdc.useModule('ti.sysbios.family.c66.Cache');
var Startup = xdc.useModule('xdc.runtime.Startup');
var System = xdc.useModule('xdc.runtime.System');
var Settings = xdc.useModule('ti.sysbios.posix.Settings');
Settings.supportsMutexPriority = true;
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
heapMemParams.size = 0x3D000;
heapMemParams.sectionName = "systemHeap";
Program.global.heap0 = HeapMem.create(heapMemParams);
Memory.defaultHeapInstance = Program.global.heap0;
Program.sectMap["sharedL2"] = "MSMCSRAM";
Program.sectMap["systemHeap"] = "MSMCSRAM";
Program.sectMap[".sysmem"] = "MSMCSRAM";
Program.sectMap[".args"] = "MSMCSRAM";
Program.sectMap[".cio"] = "MSMCSRAM";
Program.sectMap[".rodata"] = "MSMCSRAM";
Program.sectMap[".neardata"] = "MSMCSRAM";
Program.sectMap[".cppi"] = "MSMCSRAM";
Program.sectMap[".init_array"] = "MSMCSRAM";
Program.sectMap[".qmss"] = "MSMCSRAM";
Program.sectMap[".cinit"] = "MSMCSRAM";
Program.sectMap[".bss"] = "MSMCSRAM";
Program.sectMap[".const"] = "MSMCSRAM";
Program.sectMap[".text"] = "MSMCSRAM";
Program.sectMap[".code"] = "MSMCSRAM";
Program.sectMap[".switch"] = "MSMCSRAM";
Program.sectMap[".data"] = "MSMCSRAM";
Program.sectMap[".vecs"] = "MSMCSRAM";
Program.sectMap["emacComm"] = "L2SRAM";
Program.sectMap[".far:taskStackSection"] = "L2SRAM";
Program.sectMap[".stack"] = "L2SRAM";
Program.sectMap["platform_lib"] = "L2SRAM";
Program.sectMap[".fardata:benchmarking"] = "DDR3";
Program.sectMap[".dstBufSec"] = "L2SRAM";
Program.sectMap[".testData"] = "L2SRAM";
Program.sectMap[".srioSharedMem"] = "MSMCSRAM";
SysStd = xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy = SysStd;
Startup.lastFxns.$add('&EVM_init');
BIOS.taskEnabled = true;
var drv = xdc.loadPackage ("ti.sdo.edma3.drv");
var rm = xdc.loadPackage ("ti.sdo.edma3.rm");
var Event = xdc.useModule('ti.sysbios.knl.Event');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var CpIntc = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc');
var ECM = xdc.useModule ("ti.sysbios.family.c64p.EventCombiner");
var HWI = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var halCache = xdc.useModule('ti.sysbios.hal.Cache');
ECM.eventGroupHwiNum[0] = 7;
ECM.eventGroupHwiNum[1] = 8;
var Utils = xdc.loadPackage('ti.utils.profiling');
var Pcie = xdc.loadPackage('ti.drv.pcie');
Pcie.Settings.enableProfiling = true;
BIOS.smpEnabled = true;
Clock.timerId = -1;
Clock.swiPriority = 15;
Global.IPv6 = false;
environment['xdc.cfg.check.fatal'] = 'false';
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Log = xdc.useModule('xdc.runtime.Log');
var Cppi = xdc.loadPackage('ti.drv.cppi');
var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.translate = false;
var memmap = Program.cpu.memoryMap;
Program.sectMap[".my_sect_iram"] = "L2SRAM";
Program.sectMap[".my_sect_ddr"] = "L2SRAM";
/* ======== gpio_test.cfg ========/
Task.deleteTerminatedTasks = false;
BIOS.swiEnabled = true;
Program.sectMap[".csl_vect"] = "L2SRAM";
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var core = xdc.useModule('ti.sysbios.hal.Core');
var Board = xdc.loadPackage('ti.board');
Board.Settings.boardName = "evmC6657";
var Gpio = xdc.loadPackage('ti.drv.gpio');
Gpio.Settings.socType = devType;
var Uart = xdc.useModule('ti.drv.uart.Settings');
Uart.socType = devType;
Task.checkStackFlag = false;
var memmap = Program.cpu.memoryMap;
************ Console:*******************
DigitalProc TestBench SW Ver 0.0.1 Build 46 CPU Freq 1000 MHz DSP's core 1 of 2
DSP hw rev. 0 DSP name "TMS320C6657" Board Name "TMDXEVM6657L"
MAC0: 00:18:30:0A:22:88
00:00:00 00:00:07 PciExMain.c@2223: Start PciExMain taskname "PciExTask"
00:00:00 00:00:00 PciExMain.c@2258: Version #: 0x02020007; string PCIE LLD Revision: 02.02.00.07:Dec 13 2016:16:29:29
00:00:00 00:00:00 FPGAInterrupt.c@209: Start mainFPGA taskname "FpgaTask"
00:00:00 00:00:00 FPGAInterrupt.c@280: Debug: GEM-INTC INT4 EventID89
00:00:00 00:00:00 FPGAInterrupt.c@300: Debug: GEM-INTC Configuration Completed
00:00:00 00:00:00 FPGAInterrupt.c@327: Debug: GEM-INTC IRQ waiting
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 3
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 5
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 6
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 12
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 14
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 18
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 21
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 22
00:00:00 00:00:00 FPGAInterrupt.c@370: GPIO interrupt occurs a = 23
I suppose that the HWI CSL_INTC_VECTID_4 is already used in TI RTOS as timer schedule
(or some other using), when I use this vectID the RTOS remains blocked .
If I can't use this vectID which other one I can use?
Where is my mistake ? or I have missed something?
Best Regards
Dario