Thread 中讨论的其他器件:SysConfig、 C2000WARE
工具/软件:
您好 TI、
我尝试让一个 CPU 计时器为 Modbus 库工作。 我下面是 timer_ex1_cputimer_sysconfig 示例。
CPU 计时器在 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;
}






