本帖最后由 redgalaxy 于 2010-3-10 10:40 编辑
我使用的时2812 CCS3.1
void init_eva_timer1(void)
{
// Initialize EVA Timer 1:
// Setup Timer 1 Registers (EV A)
EvaRegs.GPTCONA.all = 0;
// Set the Period for the GP timer 1 to 0x0200;
EvaRegs.T1PR = 0x0200; // Period
EvaRegs.T1CMPR = 0x0000; // Compare Reg
// Enable Period interrupt bits for GP timer 1
// Count up, x128, internal clk, enable compare, use own period
EvaRegs.EVAIMRA.bit.T1PINT = 1;
EvaRegs.EVAIFRA.bit.T1PINT = 1;
// Start EVA ADC Conversion on timer 1 Period interrupt 周期中断启动ADC
EvaRegs.GPTCONA.bit.T1TOADC = 2;
// Clear the counter for GP timer 1 连续增计数模式
EvaRegs.T1CNT = 0x0000;
EvaRegs.T1CON.all = 0x1742;
}
void init_eva_timer2(void)
{
// Initialize EVA Timer 2:
// Setup Timer 2 Registers (EV A)
EvaRegs.GPTCONA.all = 0;
// Set the Period for the GP timer 2 to 0x0200;
EvaRegs.T2PR = 0x0400; // Period
EvaRegs.T2CMPR = 0x0000; // Compare Reg
// Enable Period interrupt bits for GP timer 2
// Count up, x128, internal clk, enable compare, use own period
EvaRegs.EVAIMRB.bit.T2PINT = 1;
EvaRegs.EVAIFRB.bit.T2PINT = 1;
// Clear the counter for GP timer 2
EvaRegs.T2CNT = 0x0000;
EvaRegs.T2CON.all = 0x1742;
//Start EVA ADC Conversion on timer 2 Period interrupt
//EvaRegs.GPTCONA.bit.T2TOADC = 2;只能由定时器2启动,屏蔽该位AD转换就不正确
}
哪位大虾给一下合理的解释! |