我的主函数里对timer进行初始化, 调用Timer_Config(); void Timer_Config(void)
{
Uint16 EventId;
//Temporarily disable all maskable interrupts
IRQ_globalDisable();
//打开TIMER0,获得句柄
hGpt1 = GPT_open(GPT_DEV1, GPT_OPEN_RESET);
//获得TIMER0中断号
EventId = GPT_getEventId(hGpt1);
//Clear any pending Timer interrupts
IRQ_clear(EventId);
//Place interrupt service routine address at associated vector location
IRQ_plug(EventId,&Timer1Isr);
//Enable Timer0 interrupt
IRQ_enable(EventId);
//初始化TIMER0
GPT_config(hGpt1, &MyGpt1Config);
//Enable all maskable interrupts
IRQ_globalEnable();
/* Restore initial interrupts
*/
}
其中MyGptConfig是这样的
GPT_Config MyGpt1Config = {
0,
//Emulation management register,当仿真器问询时,始终停止工作
0,
//GPIO interrupt control register 内部时钟产生中断,而不是TIM1管脚输入作为中断
0,
//GPIO enable register TIMn端口functions as a timer output/input而不是GPIO mode
//GPIO functionality can be enabled in GPEN only when the timer is reset
//(TIM12RS = 0 and TIM34RS = 0 in GCTL1).
0,
//GPIO direction register
0,
//GPIO data register
TIMER1,
//Timer period register 1,90Mhz/2k,时间间隔为0.5ms
0,
//Timer period register 2
0,
//Timer period register 3
0,
//Timer period register 4
GPT_GPTCTL1_RMK(
//Timer control register 1
0,//GPT_GPTCTL1_TIEN_NOT_GATED, //输入时钟不加门限,含义见时钟模块电路图
0,//GPT_GPTCTL1_CLKSRC_VBUS, //时钟源采用内部时钟
GPT_GPTCTL1_ENAMODE_CONTINUOUS, //计数器连续计数模式
GPT_GPTCTL1_PWID_INACTIVE_1CYCLE,//在时钟模式下无用
GPT_GPTCTL1_CP_CLOCK_MODE,//输出时钟模式,输出电平自动跳转,占空比恒定为50%
GPT_GPTCTL1_INVIN_DONT_INVERT_OUTPUT,//时钟输入不翻转
GPT_GPTCTL1_INVOUT_DONT_INVERT_OUTPUT//时钟输出不翻转
),
GPT_GPTCTL2_RMK(
//Timer control register 2
GPT_GPTCTL2_TIEN_NOT_GATED,
GPT_GPTCTL2_CLKSRC_VBUS,
GPT_GPTCTL2_ENAMODE_CONTINUOUS,
GPT_GPTCTL2_PWID_INACTIVE_1CYCLE,
GPT_GPTCTL2_CP_CLOCK_MODE,
GPT_GPTCTL2_INVIN_DONT_INVERT_OUTPUT,
GPT_GPTCTL2_INVOUT_DONT_INVERT_OUTPUT
),
GPT_GPTGCTL1_RMK(
//Global timer control register
GPT_GPTGCTL1_PSC34_DEFAULT, //prescale period = 0
GPT_GPTGCTL1_TIMMODE_DEFAULT, //64BIT_GPTIM 000000u,The timer is in the 64-bit general-purpose timer mode.
GPT_GPTGCTL1_TIM34RS_NOT_IN_RESET, //0x0001u, 64BIT_GPTIM必须
GPT_GPTGCTL1_TIM12RS_NOT_IN_RESET //0x0001u, 64BIT_GPTIM必须
)
};
TIMER1是个宏,我现在想在程序里实时修改TIMER1的值不知道怎么办?因为不能把它变成变量,否则提示不能通过编译。
谢谢各位了
//初始化TIMER0
GPT_config(hGpt1, &MyGpt1Config);
//Enable all maskable interrupts
IRQ_globalEnable();
/* Restore initial interrupts
*/
}
|