Timer0 of PIC 16F887

Home Forums Microcontrollers PIC Microcontroller Timer0 of PIC 16F887

This topic contains 1 reply, has 2 voices, and was last updated by  Ligo George 2 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10509

    chirag patel
    Participant

    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;
      }
    }
    
    #10518

    Ligo George
    Keymaster

    Hello,

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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.