Other Parts Discussed in Thread: SYSBIOS
Hi TI,
I'd like to create a timer module using c code. can you give me any example for that?
I have referred TI SYS/BIOS user's guide runtime example from p176 to p177
I just copied and pasted the example code in my project however error occurred and i couldn't figure out what matter is.
the code in red is what I have included. and whenever this code run, this error message is seen on CCS console.
xdc.runtime.Core: line 87: assertion failure: A_initializedParams: uninitialized Params struct
xdc.runtime.Error.raise: terminating execution
ti.sysbios.knl.Semaphore: line 311: assertion failure: A_badContext: bad calling context. Must be called from a Task.
xdc.runtime.Error.raise: terminating execution
ti.sysbios.knl.Semaphore: line 311: assertion failure: A_badContext: bad calling context. Must be called from a Task.
xdc.runtime.Error.raise: terminating execution
ti.sysbios.knl.Semaphore: line 311: assertion failure: A_badContext: bad calling context. Must be called from a Task.
xdc.runtime.Error.raise: terminating execution
I'd like to create and delete any module freely without help of XGCONF
and how can I load my RTOS application in a memory such as FLASH?
I have noticed my application seems to be erased after power on reset , which seems like my application is loaded in SARAM before power on reset.
many thanks
/*
* ======== main.c ========
*/
#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/timer.h>
#include "F28x_Project.h"
Uint32 j = 0;
Uint32 k = 0;
Uint32 ModifyFreq = 5000;
Timer_Handle timerHandle;
//Timer_Handle timerHandle;
//Task_Handle task;
//Error_Block eb;
/*
* ======== TimerISR ========
*/
void TimerISR()
{
j++;
if(j >= ModifyFreq){
j = 0;
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;
}
}
void TimerISR1();
/*
* ======== 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 */
}
Void tickFxn(UArg arg0)
{
k++;
}
/*
* ======== main ========
*/
Int main()
{
Timer_Params timerParams;
Timer_Handle timerHandle;
Task_Handle task;
Error_Block eb;
System_printf("enter main()\n");
Error_init(&eb);
task = Task_create(taskFxn, NULL, &eb);
if (task == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}
Timer_Params_init(&timerParams);
timerParams.period = 2000; /* 2 ms */
timerHandle = Timer_create(Timer_ANY, tickFxn, &timerParams, &eb);
if (timerHandle == NULL) {
System_abort("Timer create failed");
}
//gpio34, gpio31
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
EDIS;
BIOS_start(); /* does not return */
return(0);
}
void TimerISR1()
{
k++;
// System_printf("Current period = %d\n",Timer_getPeriod(timerHandle));
}