Timer0 of PIC 16F887 – electroSome https://electrosome.com/topic/timer0-of-pic16f887/feed/ Sat, 18 Mar 2023 04:56:32 +0000 https://bbpress.org/?v=2.6.9 en-US https://electrosome.com/topic/timer0-of-pic16f887/#post-10509 <![CDATA[Timer0 of PIC 16F887]]> https://electrosome.com/topic/timer0-of-pic16f887/#post-10509 Sun, 18 Jan 2015 04:00:28 +0000 chirag patel hi, i m trying to interrupt timer on specific time but its doing randomly please help me out.

#include <htc.h>
unsigned  char vary,count=10;
#define _XTAL_FREQ 4000000

void main()
{
  TRISD=0b00000000;
  //PORTD=0b00000000;

  GIE=1;
  T0IE=1;
  TMR0=0;
  PSA=0;
  T0CS=0;
  PS0=1;
  PS1=1;
  PS2=0;
  T0SE=1;

  while (1)
  {
    PORTD=0b00000000;
  }
}
static void interrupt isr()
{
  if (T0IF == 1)
  {
    GIE=0;
    T0IF=0;
    vary++;
    if (vary=1)
    {
      PORTD= 0b11111111;
    }
    vary=0;
    GIE=1;
    T0IE=1;
  }
}
]]>
https://electrosome.com/topic/timer0-of-pic16f887/#post-10518 <![CDATA[Reply To: Timer0 of PIC 16F887]]> https://electrosome.com/topic/timer0-of-pic16f887/#post-10518 Mon, 19 Jan 2015 14:21:01 +0000 Ligo George Hello,

The interrupt will generate when the Timer Overflows… you can change its time period by adjusting the prescaler value.

]]>