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.
Tool/software: TI-RTOS
Please I need help,
System timer seem not running at all, Idle task and other SCI interrupt are running good,
I also add cpu timer in the .cfg and still not working. something else is missing and I do not know where.
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var GIO = xdc.useModule('ti.sysbios.io.GIO');
var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
var Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
var Timestamp = xdc.useModule('xdc.runtime.Timestamp');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var ti_sysbios_family_c28_Timer = xdc.useModule('ti.sysbios.family.c28.Timer');
Boot.bootFromFlash = true;
Boot.configureFlashController = false;
//var Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
System.SupportProxy = SysStd;
System.SupportProxy = SysMin; /* not really necessary since SysMin is the default */
SysMin.bufSize = 0x1000;
SysMin.flushAtExit = true;
System.maxAtexitHandlers = 4;
BIOS.heapSize = 0x800;
BIOS.libType = BIOS.LibType_Custom;
/* System stack size (used by ISRs and Swis) */
Program.stack = 512;
/* 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;
//BIOS.logsEnabled = true;
//BIOS.assertsEnabled = true;
BIOS.clockEnabled = true;
BIOS.customCCOpts = "-v28 -DLARGE_MODEL=1 -ml -q -mo --program_level_compile -o3 -g";
Idle.idleFxns[0] = "&Idle";
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
Boot.disableWatchdog = true;
Boot.bootCPU2 = false;
Boot.configSharedRAMs = false;
BIOS.common$.diags_ASSERT = Diags.ALWAYS_ON;
BIOS.logsEnabled = false;
BIOS.assertsEnabled = false;
BIOS.rtsGateType = BIOS.GateSwi;
BIOS.cpuFreq.lo = 2500000;
BIOS.heapTrackEnabled = true;
Clock.tickSource = Clock.TickSource_TIMER;
Clock.tickPeriod = 100;
var clock0Params = new Clock.Params();
clock0Params.instance.name = "clock0";
clock0Params.startFlag = true;
clock0Params.period = 500;
Program.global.clock0 = Clock.create("&myclk", 1000, clock0Params);
var ti_sysbios_family_c28_Timer0Params = new ti_sysbios_family_c28_Timer.Params();
ti_sysbios_family_c28_Timer0Params.instance.name = "ti_sysbios_family_c28_Timer0";
ti_sysbios_family_c28_Timer0Params.period = 5;
ti_sysbios_family_c28_Timer0Params.emulationModeInit.free = 1;
Program.global.ti_sysbios_family_c28_Timer0 = ti_sysbios_family_c28_Timer.create(null, "&mytimer", ti_sysbios_family_c28_Timer0Params);
Main()
// one shot timer
Clock_Params_init(&clkParams);
clkParams.period = 0;
clkParams.startFlag = TRUE;
clk1 = Clock_create(clk0Fxn, 1000, &clkParams, &eb);
// periodic timer
Clock_Params_init(&clkParams);
clkParams.period = 50;
clkParams.startFlag = TRUE;
clk2 = Clock_create(clk1Fxn, 1000, &clkParams, &eb);
if ((clk1 == NULL) || (clk2 == NULL))
BIOS_exit(0);
......
BIOS_Start();
}
/*
* ======== clk0Fxn =======
*/
Void clk0Fxn()
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
System_printf("clk0Fxn %d: time is %d : %d\n", mtime,time);
System_flush();
}
// cpu_timer
Void myclk ()
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
// cpu_timer
Void mytimer ()
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
/*
* ======== clk1Fxn =======
*/
Void clk1Fxn()
{
UInt32 ntime;
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
I got the periodic default ISR interrupt void TIMER0_ISR(void)
I was expecting to get myTimer()
I know I doing something wrong not sure what.
TRemaining is struck
Hi Jeanluc,
Can you tell me which SDK version you are using?
Additionally, could you post a screen shot of the 'Clock' view in ROV before and after you start the application in debug mode? If you can, the 'detailed' view has the most info.
I noticed that your clock0 is defined to run myclk() and not myTimer() but maybe that is what you meant. Also, you may want to remove the duplicate System.SupportProxy definitions, to make your cfg more straight forward.
Thanks,
Sean
Sean,
Thank you so much to reply
My CCS is 9.0.1.00004 / Bios 6_76_00_08
I want to use the sys clock with the function call "myclk" see my .cfg , and I defined Clk0Fxn and Clk1Fxn in the main, the first figure is before start ( still first break point in Main) and second figure is running after few second ( notice tRemaining is not moving ) the tick clock seems not running at all . I want to understand why Clk0Fxn and Clk1Fxn are not working myClk , I also created myTimer as test only and it's not working as well, something is wrong with my setup. Timer"xx"_ISR seems to work.
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 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 Task = xdc.useModule('ti.sysbios.knl.Task');
var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var GIO = xdc.useModule('ti.sysbios.io.GIO');
var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
var Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
var Timestamp = xdc.useModule('xdc.runtime.Timestamp');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var ti_sysbios_family_c28_Timer = xdc.useModule('ti.sysbios.family.c28.Timer');
Boot.bootFromFlash = true;
Boot.configureFlashController = false;
//var Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
System.SupportProxy = SysStd;
SysMin.bufSize = 0x1000;
SysMin.flushAtExit = true;
/*
* 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;
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 = 512;
/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;
//BIOS.logsEnabled = true;
//BIOS.assertsEnabled = true;
BIOS.clockEnabled = true;
BIOS.customCCOpts = "-v28 -DLARGE_MODEL=1 -ml -q -mo --program_level_compile -o3 -g";
Idle.idleFxns[0] = "&Idle";
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
Boot.disableWatchdog = true;
Boot.bootCPU2 = false;
Boot.configSharedRAMs = false;
BIOS.common$.diags_ASSERT = Diags.ALWAYS_ON;
BIOS.logsEnabled = false;
BIOS.assertsEnabled = false;
BIOS.rtsGateType = BIOS.GateSwi;
BIOS.cpuFreq.lo = 2500000;
BIOS.heapTrackEnabled = true;
Clock.tickSource = Clock.TickSource_TIMER;
Clock.tickPeriod = 5000;
var clock0Params = new Clock.Params();
clock0Params.instance.name = "clock0";
clock0Params.startFlag = true;
clock0Params.period = 500;
Program.global.clock0 = Clock.create("&myclk", 1000, clock0Params);
var ti_sysbios_family_c28_Timer0Params = new ti_sysbios_family_c28_Timer.Params();
ti_sysbios_family_c28_Timer0Params.instance.name = "ti_sysbios_family_c28_Timer0";
ti_sysbios_family_c28_Timer0Params.period = 10000;
ti_sysbios_family_c28_Timer0Params.emulationModeInit.free = 1;
Program.global.ti_sysbios_family_c28_Timer0 = ti_sysbios_family_c28_Timer.create(null, "&mytimer", ti_sysbios_family_c28_Timer0Params);
Hi Jeanluc,
Thanks for getting that information for me. Unfortunately the links to the pictures appear to be broken. Instead of the pictures, I see little 'broken link 'icons. Do they show up in the forum for you? If not, could you reupload them or maybe upload them to a third party image host like imgur.com and post a link to that here?
Thanks,
Sean
interrupt void TIMER0_ISR(void);
interrupt void mytimer();
Void myclk();
Void clk0Fxn();
Void clk1Fxn();
#define NUMMSGS 3 /* number of messages */
#define TIMEOUT 12 /* timeout value */
#define HighPriority 16
#define DATA8(a,b) (a<<8 + b)
#define DATA16(a,b) (a<<16 + b)
#define Delay 20000;
Clock_Handle clk1, clk2;
#define NUMMSGS 3 /* number of messages */
#define TIMEOUT 12 /* timeout value */
/* Counter incremented by timer interrupt */
UInt32 timepr,mtime;
static UInt32 t0, t1,deltatime,idletime,prvt0,ptimer;
Types_FreqHz freq;
/*
* ======== main ========
*/
Int main()
{
UInt32 ntime;
System_printf("Enter Main \n");
System_flush();
InitSysCtrl();
Clock_Params clkParams;
Error_Block eb;
Error_init(&eb);
//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2807x_PieCtrl.c file.
//
InitPieCtrl();
//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
IER = 0x0000;
IFR = 0x0000;
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in F2807x_DefaultIsr.c.
// This function is found in F2807x_PieVect.c.
//
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
//INT | Enable CPU INT
EINT; //INT | Enable Global interrupt INTM
ERTM; //INT | Enable Global realtime interrupt DBGM
IER |= M_INT1; //INT | Enable CPU INT1 which is connected to CPU-Timer 0:
EDIS;
Clock_Params_init(&clkParams);
clkParams.period = 0;
clkParams.startFlag = TRUE;
clk1 = Clock_create(clk0Fxn, 1000, &clkParams, &eb);
Clock_Params_init(&clkParams);
clkParams.period = 50;
clkParams.startFlag = TRUE;
clk2 = Clock_create(clk1Fxn, 1000, &clkParams, &eb);
if ((clk1 == NULL) || (clk2 == NULL))
BIOS_exit(0);
System_printf("DONE Start Bios \n");
System_flush();
Log_info0("DONE \n");
ntime = Clock_getTicks() ;
ERTM; // Enable Global realtime interrupt DBGM
/*
* Start BIOS.
* Begins task scheduling.
*/
BIOS_start(); /* does not return */
return(0);
}
//
// 1.7 - Timer 0 Interrupt
//
interrupt void TIMER0_ISR(void)
{
//
// Insert ISR Code here
//
//
// To receive more interrupts from this PIE group,
// acknowledge this interrupt.
// PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
//
//
// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
/* Nothing to do
*
*/
Void Idle(Void)
{
// System_printf("Idle taskFxn() \n");
// System_flush();
prvt0 = t0;
t0 = Timestamp_get32();
float SysCLK = t0/(freq.lo / 1000); //ms frq 50000000 50M
ptimer = ((t0 - prvt0)*1000)/50000;
idletime = ((t0 - t1)*1000)/50000;
if (++LedCnt%1000 == 0 ) {
isrFlag = !isrFlag ;
}
t1 = Timestamp_get32();
//deltatime = (t1-t0)/ (freq.lo / 1000);
//deltatime = _IQdiv(_IQ(1),_IQ(1));
//deltatime = _IQdiv(t1 , (freq.lo / 1000)); //ms frq 50000000 50M
deltatime = ((t1 - t0)*1000)/50000;
//Turn LED ON/OFF
GPIO_WritePin(42, 1);
GPIO_WritePin(43, 1);
GPIO_WritePin(42, 1);
}
/*
* ======== clk0Fxn =======
*/
Void clk0Fxn()
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
System_printf("clk0Fxn %d: time is %d : %d\n", mtime,time);
System_flush();
}
Void myclk ()
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
interrupt void mytimer ( )
{
UInt32 ntime;
//Do nothing with this event yet
//Event_post(evt, Event_Id_02);
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
/*
* ======== clk1Fxn =======
*/
Void clk1Fxn()
{
UInt32 ntime;
ntime = Clock_getTicks() ;
mtime= ntime - timepr;
timepr = ntime;;
}
Hi Jeanluc,
Here are some things I would try:
- I don't know what the rest of your code is doing, put if a thread is pending on a semaphore and another thread posts() the semaphore, it is expected that the pending thread is unblocked (cleared) as you show. This is the expected behavior.
- I strongly recommend you start from a fresh .cfg file and add back in the things you need. There is quite a bit of duplication and overwriting in your current cfg file that could be causing all kinds of issues. I have attached a .cfg and .c file for the BIOS clock examples for your board that you can use as a baseline.
- Please note that if you are not using sysmin, you cannot printf from a clock function because this runs in Hwi/Swi context.
- I recommend you move the clock object you are statically creating in your cfg into your c file and create it the same way you are making clk1 and clk2. That is, you should create all your clocks in the same place.
- See the examples in your BIOS install as reference for how to configure Clocks, PIEs, Swis etc for your specific device. You actually have to install an older CCS to do this (such as CCS8) because you must use the Resource Viewer CLASSIC which is no longer in CCS9.
/* * ======== clock.c ======== * The clock example shows how to use the ti.sysbios.knl.Clock module to * create one-shot and periodic Clock Instances. Clock Instances are * essentially functions that run after a certain number of Clock ticks. */ #include <xdc/std.h> #include <xdc/runtime/System.h> #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Clock.h> Void clk0Fxn(UArg arg0); Void clk1Fxn(UArg arg0); /* * ======== main ======== */ Int main() { Clock_Handle clk2; Clock_Params clkParams; /* Create a periodic Clock Instance with period = 5 system time units */ Clock_Params_init(&clkParams); clkParams.period = 5; clkParams.startFlag = TRUE; Clock_create(clk0Fxn, 5, &clkParams, NULL); /* Create an one-shot Clock Instance with timeout = 11 system time units */ clkParams.period = 0; clkParams.startFlag = FALSE; clk2 = Clock_create(clk1Fxn, 11, &clkParams, NULL); Clock_start(clk2); BIOS_start(); /* does not return */ return(0); } /* * ======== clk0Fxn ======= */ Void clk0Fxn(UArg arg0) { UInt32 time; time = Clock_getTicks(); System_printf("System time in clk0Fxn = %lu\n", (ULong)time); } /* * ======== clk1Fxn ======= */ Void clk1Fxn(UArg arg0) { UInt32 time; time = Clock_getTicks(); System_printf("System time in clk1Fxn = %lu\n", (ULong)time); System_printf("Calling BIOS_exit() from clk1Fxn\n"); BIOS_exit(0); }
Thanks,
Sean
Sean
About the semaphore you found and nailed it.
This semaphore was reentrant from an other interrupt, my bad.
I will restart with your Clock.c and clk.cfg
Thank u so much
Jeanluc