Other Parts Discussed in Thread: SYSCONFIG, C2000WARE
Tool/software:
Hello TI,
I am trying to get a CPU Timer working for a modbus library. I am following timer_ex1_cputimers_sysconfig example.
The CPU Timer is tested in main(),
void main(void)
{
//Vars
//Modbus
eMBErrorCode eStatus;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Disable sync(Freeze clock to PWM as well). GTBCLKSYNC is applicable
// only for multiple core devices. Uncomment the below statement if
// applicable.
//
// SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_GTBCLKSYNC);
//SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// PinMux and Peripheral Initialization
//
Board_init();
//
// Enable sync and clock to PWM
//
//SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// C2000Ware Library initialization
//
C2000Ware_libraries_init();
//
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
//
EINT;
ERTM;
xMBPortTimersInit( 20 );
vMBPortTimersEnable( );
while(1)
{
}
}
BOOL
xMBPortTimersInit( USHORT usTim1Timerout50us )
{
EALLOW;
CPUTimer_setEmulationMode(myCPUTIMER0_BASE, CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_setPreScaler(myCPUTIMER0_BASE, 0U);
//Set the period for the MB Library.
CPUTimer_setPeriod(myCPUTIMER0_BASE, 120U);
CPUTimer_enableInterrupt(myCPUTIMER0_BASE);
CPUTimer_stopTimer(myCPUTIMER0_BASE);
CPUTimer_reloadTimerCounter(myCPUTIMER0_BASE);
Interrupt_register(myCPUTIMER0_BASE, &prvvTIMERExpiredISR);
Interrupt_enable(myCPUTIMER0_BASE);
EDIS;
return TRUE;
}inline void
vMBPortTimersEnable( )
{
EALLOW;
CPUTimer_startTimer(myCPUTIMER0_BASE);
EDIS;
}inline void
vMBPortTimersDisable( )
{
EALLOW;
CPUTimer_stopTimer(myCPUTIMER0_BASE);
EDIS;
}






