• AVR Freaks

Hot!Interrupt on Change PIC16F18326

Page: 12 > Showing page 1 of 2
Author
Theo
Starting Member
  • Total Posts : 42
  • Reward points : 0
  • Joined: 2019/05/04 18:51:24
  • Location: 0
  • Status: offline
2020/01/16 12:36:52 (permalink)
0

Interrupt on Change PIC16F18326

Hi,
I'm trying to mesure the speed of 2 attached fans. These tacho signals are generated by the fans itself, and are pulled-up by 2 small resistors (510 Ohm). I'm using pins RA5 and RA4 for this. Both pins are set as digital inputs.
I want to use the IOC module for this, but this seems to work only on pin RA5, not on pin RA4. Both input signals look very much alike on a scope and nothing else is connected to these pins.
 
Am I missing something?
 
Attached is a very small assembly  program, doing nothing but this, but it won't work. Only when I change IOCAN4 to IOCAN5 I get interrupts (breakpoints show this). Changing the value of the pull-up resistors, nor swapping the fans helps.
#1

34 Replies Related Threads

    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/16 12:47:40 (permalink)
    0
    Two issues, but nether are your problem cause.
     
    Why are you setting LATA4 and LAT5, when those pins are inputs?
     
    Don't do this
        BANKSEL PORTC
        BSF        PORTC,RC1            ; relais on

    Always use LATx registers for output, only use PORTx pins for input.
     
    Do note, this test code would lock up into the ISR as soon as you get one interrupts, because you don't clear it before exiting the ISR.
     
    My one suspicion with the actual problem would be that RA4 is shared with CLKOUT/OSC2, but you do appear to have disabled those functions correctly.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 13:29:57 (permalink)
    0
    Thanks for trying.
     
    Setting LATA4 and LATA5 is one of my desperate attempts to get it working. I'm almost ready for the funny-farm.
     
    And yes, that interrupt routine is just kept as short as possible.
     
    BTW: I forgot to mention that I replaced the chip as well (a 14 pin dip version).
    #3
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/16 14:19:53 (permalink)
    0
    Is it only RA4 not working?
    Are you able to try on any other IOC pins? (Apart from RA5, which you already know works)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 14:56:42 (permalink)
    0
    I can try, this time on a breadboard. The previous attempt was on a PCB.
     
    I will do this tomorrow, it's about bedtime here (and for you, you're out early or still awake late).
    #5
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:01:12 (permalink)
    0
    Theo de Kok
    I will do this tomorrow, it's about bedtime here (and for you, you're out early or still awake late).

    It's 9am here now. My first answer was as I was eating breakfast around 6:30am :)
    post edited by ric - 2020/01/16 15:02:35

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    coffee critic
    Super Member
    • Total Posts : 391
    • Reward points : 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:31:38 (permalink)
    0
    Do RA4 and RA5 pullups reference the same supply as the PIC16?

    n_*$
    #7
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:37:41 (permalink)
    0
    coffee critic
    Do RA4 and RA5 pullups reference the same supply as the PIC16?

    Interesting point.
    Also note, both RA4 and RA5 can be set to either ST or TTL input thresholds.
    The INLVLA register is never initialised, so will still have the default 0x3F setting, making all pins "ST" threshold.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:38:28 (permalink)
    0
    Yes, it's the same +5V as the PIC gets.
    #9
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:41:27 (permalink)
    0
    I remember trying the INVLA register in the main program, not in the short version.
     
    Makes no difference.
    #10
    coffee critic
    Super Member
    • Total Posts : 391
    • Reward points : 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:41:32 (permalink)
    0
    Same supply. That takes positive current injection off the table. 

    n_*$
    #11
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/16 15:49:32 (permalink)
    0
    Can you actually read the RA4 pin?
    What about a tight loop just copying its value to another pin?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 08:51:36 (permalink)
    0
    I never tried if I can read the RA4 pin.
    And a tight loop is in my opinion not the answer. Very time consuming and I don't know if writing to a pin produces interrupts. My main program has a lot of other things to do, so time will be precious. And I don't have a free pin left.
     
    I'm currently trying to built a test circuit on a breadboard. But I want to do it correctly, with pullups on every unused input. But putting all these resistors on a breadboard is a real pain in the arse. SIL networks would be a lot easier, but I havn't got any. So I ordered a few and they will arrive Tuesday (worst case). So my answer if RA4 is the only problematic input will have to wait a few days.
    #13
    pcbbc
    Super Member
    • Total Posts : 1507
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 08:59:13 (permalink)
    0
    Theo de KokBut I want to do it correctly, with pullups on every unused input. But putting all these resistors on a breadboard is a real pain in the arse.

    Don't make them inputs then.  Switch them to outputs and you won't have to bother with pullups.
    #14
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 09:32:17 (permalink)
    0
    Yes, I considered that option. Would make the software somewhat more difficult though (making changes every time I want to test another pin). And the chance of making mistakes would increase.
    That is why I opted for waiting a couple of days. There is no hurry and I have lots of other things to do.
    #15
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/17 14:25:33 (permalink)
    0
    Theo de Kok
    I never tried if I can read the RA4 pin.
    And a tight loop is in my opinion not the answer. Very time consuming and I don't know if writing to a pin produces interrupts.

    You totally missed my point.
    This was not a suggested solution, it was a test to see if the pin is actually in a state so that it can be read.
    If it's not (e.g. in analog mode), then IOC can't work.
    i.e. it's just a tool to help you track down the real problem.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #16
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 14:54:21 (permalink)
    0
    Sorry for misunderstanding.
     
    No, I can't read from RA4, it's always 0.
    #17
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Interrupt on Change PIC16F18326 2020/01/17 15:08:06 (permalink)
    0
    So that is the real problem.
    Either it's in analog mode, or the secondary clock is enabled.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #18
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 15:11:05 (permalink)
    0
    For clarification:
    I removed fan1 and changed RA5 to be a digital output.
     
    Then added a few lines tot the test program (the one posted earlier).
     
    Test:
          BANKSEL  PORTA
          BTFSS      PORTA,RA4
          GOTO       Test1
          BANKSEL  LATA
          BSF          LATA,LATA5
          GOTO       Test
    Test1:
           BCF         LATA,LATA5
           GOTO      Test
     
    A scope attached to RA5 reads 0.
    #19
    Theo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2019/05/04 18:51:24
    • Location: 0
    • Status: offline
    Re: Interrupt on Change PIC16F18326 2020/01/17 15:18:53 (permalink)
    0
    But that portpin is set to digital and clockout is disabled in the configuration.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5