Menu

Question on interrupt (INT pin) on PIC16F18346

Help
jackjames
2018-10-01
2018-10-02
  • jackjames

    jackjames - 2018-10-01

    Question on interrupt (INT pin) on PIC16F18346

    I would like to use this micro and the interrupt on the INT pin.
    In other micro (Eg PIC16F1847) the rising or falling edge is changed with the OPTION_REG.INTEDG register.
    On the PIC16F18346 instead the INTEDG bit is on the INTCON register and is read only, so the rising or falling edge should be set (in my opinion) with the IOCxP or IOCxN registers.
    This is what I understand by reading the datasheet.
    I would like to know if any of you have ever used this micro (or equivalent) and have ever used the INT pin.

    Thanks

     
    • Chuck Hellebuyck

      I believe the datasheet has a typo. It's missing a W.
      It shows R-1/1 when it should say R/W-1/1 like other devices.
      The second 1 in 1/1 is meaningless otherwise.

      That bit needs to be writeable to set the edge.

       
  • Chris Roper

    Chris Roper - 2018-10-01

    I haven't used it, and am puerly speculating here, but I would think that the EDG bit in the INTCON register will be set or cleared so that your interrupt routine can determine if the interrupt on change event was rising or falling.

    Very useful for pulse width measurement without the need to have two interrupt routines.
    Your code would simply read something like:

    Sub IntOnChange_Event
    If EDG then 
    ‘ Rising edge Code
    Else
        ‘ Falling edge Code
    End If
    End Sub
    

    I may well be wrong but it is food for thought,

    Cheers
    Chris

     
  • David Stephenson

    Yes I've used the INT pin(porta.2) on this device. I didn't bother setting the intcon.0 bit. It seems to be set to 1 on power-up which is just as well as I am trying to detect a rising edge (it works flawlessly BTW unlike some INT routines I've tried). The IOCxP are for interrupt on change pins.

     
  • jackjames

    jackjames - 2018-10-02

    I used the INT pin on other micro without any problem.
    For my use I have to be able to change the interval measurement both on the rising edge and on the falling edge.
    On the other microcontrollers I set the INTEDG bit to be able to set both the rising and falling edges and I had no problem.
    Also I think there is an error in the datasheet but I have not found on the network any document that confirms it.

     
  • Anobium

    Anobium - 2018-10-02

    Dataheet may be incorrect. I agree with Chuck.

    So, use PPStool. INT on RA.2 as follows.

        #chip 16F18346
    
            'Generated by PIC PPS Tool for Great Cow Basic
            'PPS Tool version: 0.0.5.22
            'PinManager data: v1.75
            'Generated for 16F18346
            '
            'Template comment at the start of the config file
            '
            #startup InitPPS, 85
            #define PPSToolPart 16F18346
    
            Sub InitPPS
    
                    'Module: EXT_INT
                    INTPPS = 0x0002    'RA2 > INT
    
            End Sub
            'Template comment at the end of the config file
    
        'EXT_INT_risingEdgeSet
          INTEDG = 1
        'EXT_INT_fallingEdgeSet
          INTEDG = 0
    
        On Interrupt ExtInt0 call IntIsr
    
        do
        loop
    
        sub IntIsr
            'interrupt handler
            if ( INTE = 1 & INTF =1 ) then
    
                INTF = 0  'clear int flage
    
            else
                  'Unhandled Interrupt
            end if
        end sub
    
     

    Last edit: Anobium 2018-10-02
  • jackjames

    jackjames - 2018-10-02

    THANKS !!!!!!

     
  • Anobium

    Anobium - 2018-10-02

    @All. A confirmed error on the datasheet.

    I had chat with Microchip support this morning. The result is....

    Thank for reporting it to us. We have noticed the difference here ourselves with this family at least. I will be contacting our dev tools divisions to see what can be done.

    So, a confirmed error in the datasheet.

     
  • jackjames

    jackjames - 2018-10-02

    Perfect !
    All is well that ends well.

     

Log in to post a comment.