Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Embedded pic12f675定时器1观察_Embedded_Pic_Mplab - Fatal编程技术网

Embedded pic12f675定时器1观察

Embedded pic12f675定时器1观察,embedded,pic,mplab,Embedded,Pic,Mplab,我在PIC12F675中使用了带溢出中断的定时器1,溢出时间约为0.5秒,在模拟中为真 溢出中断功能代码: void interrupt int_tmr1(void) { if((PIE1&(1<<0))&&(PIR1&(1<<0))) //TMR1 OVERFLOW CONDITION { GPIO^=(1<<0); //TOGGLE LED PIR1&=~(1<<0);

我在PIC12F675中使用了带溢出中断的定时器1,溢出时间约为0.5秒,在模拟中为真

溢出中断功能代码:

void interrupt int_tmr1(void) {
if((PIE1&(1<<0))&&(PIR1&(1<<0))) //TMR1 OVERFLOW CONDITION 
{
         GPIO^=(1<<0); //TOGGLE LED 
       PIR1&=~(1<<0); //CLEAR TMR1 INTERRUPT OVER FLOW FLAG
}
void中断int\u tmr1(void){

如果((1)&(1你说的是0.5秒左右,这意味着它不完全是1/2秒。你检查的是>10,这意味着它必须数到11。因此,在0.5秒时,你有5.5秒的延迟,但我敢肯定它大约是0.525秒。

不清楚你的问题是什么或你的问题是什么。因此你添加了一个计数器,需要在切换LED之前,需要触发10次中断。什么事情没有按您希望的方式发生?5秒与6秒是什么?计时器设置代码在哪里?等等。
void interrupt int_tmr1(void)
   {
      if((PIE1&(1<<0))&&(PIR1&(1<<0))) //TMR1 OVERFLOW CONDITION
      {
         static unsigned char count=0;
          if(count>10)
         {
          GPIO^=(1<<0); //TOGGLE LED 
           count=0;
          }

    else
    {

   count++;

     }

    PIR1&=~(1<<0); //CLEAR TMR1 INTERRUPT OVER FLOW FLAG
     }

 }