PIC Timer0

Discussion in 'General Electronics Chat' started by olvine, Mar 25, 2014.

  1. olvine

    Thread Starter Member

    Mar 10, 2014
    99
    0
    Hey..

    How can we turn off Timer0 after starting it in a code.
    Controller:pIC16F887
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,224
    How do you use Timer0 in your program? Like is it used to generate an interrupt
     
  3. Sensacell

    Senior Member

    Jun 19, 2012
    1,484
    383
    The timer0 control register T0CON has a bit, TMR0ON, just clear it to turn the timer off.

    (EDIT- I stand corrected, I assumed that the TIMER0 module would be the same across parts)
     
    Last edited: Mar 25, 2014
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,224
    Have you checked the datasheet before writing this:rolleyes: Look at
    TABLE 5-1: SUMMARY OF REGISTERS ASSOCIATED WITH TIMER0. Then you will find that it is no way to enable/disable Timer0 in the 16F887. You may find such a bit in other PICs but not in this one. I do that mistake now and then my self. Assuming that since register/bit is in one PIC you may find it in others PICs to
     
  5. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    7,010
    1,450
    Just set the TOCS bit of the OPTION register to 1. That reconfigures the Timer0 module as a counter. Don't clock the TOCK1 pin.
    Here's what the datasheet says:
    Edit: IMO Table 5-1 should show bits 4 and 5 of the OPTION reg shaded.
     
    Last edited: Mar 25, 2014
  6. olvine

    Thread Starter Member

    Mar 10, 2014
    99
    0
    okay thank you all.

    what does this mean ?
    PIR1 & (1<<TMR1IF)
    i am confused with 1<<TMR1IF..
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,224
    Please take a look here http://en.wikipedia.org/wiki/Bitwise_operations_in_C This should also be described in the manual. For your own sake you should dig up your compiler manual and learn to know it. It can be a great help often.
    Anyway good luck with your project
     
Loading...