+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 3
    Points: 2,109, Level: 10

    Join Date
    Nov 2010
    Posts
    176
    Helped
    0 / 0
    Points
    2,109
    Level
    10

    PEIE in PIC 16f877a and its relation with TMR0

    hello

    I am explaining TMR0 to some students, and I followed the explanation in datasheet. The datasheet says that the pin PEIE (Peripheral interrupt enable) has a relation with TMR0.

    but this is wrong. I tried to put PEIE = 0 and this did not stop TMR0 from enabling its interrupt.

    if this is in datasheet, why PEIE has no effect?
    the other question, what is the usage of PEIE? TMR0 is not considered as one of peripherals ? what are the peripherals then?


    thanks

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 4
    Points: 7,811, Level: 21

    Join Date
    Jan 2015
    Posts
    1,095
    Helped
    346 / 346
    Points
    7,811
    Level
    21

    Re: PEIE in PIC 16f877a and its relation with TMR0

    Which data sheet are you looking at?
    Looking at http://ww1.microchip.com/downloads/e...Doc/39582C.pdf Section 2.2.2.3 on page 24, it shows the INTCON register that contains a number of control bits including PEIE (the peripheral interupt enable) and the TMR0IE which enables the Timer0 interrupt (as well as TMR0IF and other bits). However I would not say that this shows that there is a relation between them.
    If you look at Figure 14-10 on page 153, you will see that PEIE does not control the TMR0IE/TMR0IF 'and' gate.
    The same figure will show you the answer to the questions in your last paragraph.
    Susan



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 81,409, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,347
    Helped
    4456 / 4456
    Points
    81,409
    Level
    69

    Re: PEIE in PIC 16f877a and its relation with TMR0

    The 16F877A and most other 16F devices split the interupts into two categories, the 'core' interrupts from TMR0, the external interrupt pin and the IOC detector, and the 'peripheral' interupts from all other sources. PEIE is the enable/disable bit for the peripheral sources but TMR0 is not in that group so it will not have any effect on its ability to generate interrupts.

    As Susan explains, if you look a the tree diagram 14.10 "interrupt logic" in the data sheet, you will see how the different interrupts and their enable bits work together.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  4. #4
    Full Member level 3
    Points: 2,109, Level: 10

    Join Date
    Nov 2010
    Posts
    176
    Helped
    0 / 0
    Points
    2,109
    Level
    10

    Re: PEIE in PIC 16f877a and its relation with TMR0

    Quote Originally Posted by Aussie Susan View Post
    Which data sheet are you looking at?
    Looking at http://ww1.microchip.com/downloads/e...Doc/39582C.pdf Section 2.2.2.3 on page 24, it shows the INTCON register that contains a number of control bits including PEIE (the peripheral interupt enable) and the TMR0IE which enables the Timer0 interrupt (as well as TMR0IF and other bits). However I would not say that this shows that there is a relation between them.
    If you look at Figure 14-10 on page 153, you will see that PEIE does not control the TMR0IE/TMR0IF 'and' gate.
    The same figure will show you the answer to the questions in your last paragraph.
    Susan
    please look at the page 55 in the same datasheet that you sent. In page 55 , it shows the bits in INTCON that associated with TMR0, and surprisingly PEIE is one of them, even if this pin does not appear in block diagram of TMR0 as you said.

    - - - Updated - - -

    Quote Originally Posted by betwixt View Post
    The 16F877A and most other 16F devices split the interupts into two categories, the 'core' interrupts from TMR0, the external interrupt pin and the IOC detector, and the 'peripheral' interupts from all other sources.
    Brian.
    then, TMR1 and TMR2 are considered peripehral interrupts? or are dealt as TMR0 as core interrupt?
    also, what made TMR0 special? And where did they say this in datasheet?



  5. #5
    Super Moderator
    Points: 81,409, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,347
    Helped
    4456 / 4456
    Points
    81,409
    Level
    69

    Re: PEIE in PIC 16f877a and its relation with TMR0

    please look at the page 55 in the same datasheet that you sent. In page 55 , it shows the bits in INTCON that associated with TMR0, and surprisingly PEIE is one of them, even if this pin does not appear in block diagram of TMR0 as you said.
    I think that's an error in the data sheet, the PEIE should be shaded. The IC is about 15 years old now so maybe Microchip are not applying corrections to old data sheets.

    then, TMR1 and TMR2 are considered peripehral interrupts? or are dealt as TMR0 as core interrupt?
    also, what made TMR0 special? And where did they say this in datasheet?
    I suspect that is for historical reasons. On older devices (that the 16F877A evolved from) there was only one timer and Microchip's policy of keeping the registers as similar as possible across the range meant they kept INTCON like it's predecessors. The addition of other timers and peripherals meant more interrupt enable bits and interrupt flags were needed and they wouldn't fit in the existing INTCON 8 bits. Sensibly, they moved them into other registers and gave them their own (PEIE) master enable bit.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.


    1 members found this post helpful.

--[[ ]]--