本帖最后由 verilog_007 于 2011-4-11 18:31 编辑
配置程序如下:
TSCR1_TEN = 0; //Timer Disable:
TSCR1_TSWAI = 1; //Timer Module Stops While in Wait
TSCR1_TSFRZ =1; //Timer and Modulus Counter Stop While in Freeze TSCR1_TFFCA = 0; TSCR1_PRNT = 1; //1 = Enables
TSCR2_TOI = 0; //Timer Overflow Interrupt disable:
TSCR2_TCRE = 0; //Timer Counter Reset disable:
PTPSR = 0b00001111;
TFLG2_TOF = 1; //Timer Overflow Flag, Set when 16-bit free-running
TIOS = 0b00000010;
TIE = 0b00000010; // Interrupt Enable
TFLG1 = 0b11111111;
TTOV = 0b00000000;
TCTL1 = 0b00000000;
TCTL2 = 0b00001000;//
CFORC = 0b00000010; //通道1初始电平通过强制输出比较为0
TCTL1 = 0b00000000;
TCTL2 = 0b00000100; //通道1电平设为翻转 TC1 = 2000;
TSCR1_TEN = 10; //Timer Enable:
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 9 Vtimch1Interrupt(void) // Enhanced timer channel 1 Interrupt
{
asm("nop");
TC1+=1999;
TFLG1 = 0b00000010;//clear flag
}
问题1,
执行如下四条语句PIT的管脚寄存器仍然是1(PIT=255)即CFORC = 0b00000010;语句没有起作用,什么原因?
TCTL1 = 0b00000000;
TCTL2 = 0b00001000;//
CFORC = 0b00000010; //通道1初始电平通过强制输出比较为0
TCTL1 = 0b00000000;
TCTL2 = 0b00000100; //通道1电平设为翻转
问题2,
比较匹配时中断是产生了,但是通道1的管脚并没有翻转(PIT=255)
问题3,
我用的是软件仿真,还有就是软件仿真和实际在芯片中运行的情况是完全一样吗?软件仿真会不会出错? |