Interrupt mystery - need some guru help


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile no more riddles, need advises

    Please, no more riddles.

    I beleive the portA has to be read prior to enabling interrupts.


    Are these steps order right?

    - enable weak pullups with OPTION_REG = %01111111 (even if I DON'T know what should be the settings for bits 0 to 6, which seem not useful for me)
    - enable WPU for desired ports, for me it should be: 010111 (no WPU for RA3 which is used as an input port) (no WPU for RA5 which is used with default 0V and is activated when 5V gets to this pin)
    - TRISA = %101111 because all porta pins has to be input except for pin RA4 which is used for R/S bit for an LCD pannel
    - TRISC = %000000 (all output)
    - PORTA.5 = 0 (I set specificaly RA5 to 0 because I want it to be LOW at the start, all other porta pins will be brought high automatically by WPU)
    - PORTC = %000000 (I set all portC pins low)
    - I initialize all my variables
    - I put some stuff here like display on LCD
    - IOCA = %101111 because I enable PORTA change interrupt for all porta pins except for the pin used for LCD R/S bit
    - INTCON = %10001000 (I enable interrupts: GIE and portachange)
    - ON INTERRUPT GOTO myroutine

    Is that correct?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    Please, no more riddles.
    There's only one riddle...why haven't you read the section I specified earlier?
    It's right there in the datasheet...Section 4.2.3, 2nd paragraph.

  3. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Angry

    Quote Originally Posted by skimask View Post
    There's only one riddle...why haven't you read the section I specified earlier?
    It's right there in the datasheet...Section 4.2.3, 2nd paragraph.
    I did.
    Never mind, I will ask in another forum.

    I think the problem comes from the fact that my RA3 is linked to nothing. I will connect it to 5V via a 10K resistor.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    Never mind, I will ask in another forum.
    I think the problem comes from the fact that my RA3 is linked to nothing. I will connect it to 5V via a 10K resistor.
    Hey, I'm just trying to help you learn how to read a datasheet...or at least read between the lines in a datasheet. Some of the information is a bit subtle.
    And yes, it's a distinct possibility that a floating input could be triggering something it shouldn't.
    Last edited by skimask; - 21st March 2008 at 00:44.

  5. #5
    Join Date
    Dec 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Wink Interrupt mystery -

    Re-Read the replys the Clue to solve your mystery is "I.O.C."...
    hopes this helps just a little

  6. #6
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Hi xnihilo,

    Don't get upset! We are only trying to help.

    A lot of posts the user just wants the answer without learning the ways of Microchip and the PIC's. They learn how to solve that problem but not how to understand the datasheet.
    Don't get me wrong, I have spent hours pulling out my hair and after posting the problem it turns out to be a simple mistake that I have made. We are all human.

    The important part of the datasheet is this bit,

    'For enabled interrupt-on-change pins, the values are
    compared with the old value latched on the last read of
    PORTA
    . The ‘mismatch’ outputs of the last read are
    OR’d together to set the PORTA Change Interrupt Flag
    bit (RAIF) in the INTCON register (Register 2-3).'

    The following tip is the last I can give. The next step is to write the program for you!

    Read the port before enabling the interupt!!!

    Regards,
    Bob

  7. #7
    Join Date
    Dec 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Post Interrupt mystery -

    A little more help. remember if any pins change state the RAIF is set in the INTCON register, you must end any mismatch on the port first then reset the RAIF bit. Can't be much more clear than this

    Mike

  8. #8
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobP View Post
    Hi xnihilo,

    Don't get upset! We are only trying to help.

    A lot of posts the user just wants the answer without learning the ways of Microchip and the PIC's. They learn how to solve that problem but not how to understand the datasheet.
    Don't get me wrong, I have spent hours pulling out my hair and after posting the problem it turns out to be a simple mistake that I have made. We are all human.

    The important part of the datasheet is this bit,

    'For enabled interrupt-on-change pins, the values are
    compared with the old value latched on the last read of
    PORTA
    . The ‘mismatch’ outputs of the last read are
    OR’d together to set the PORTA Change Interrupt Flag
    bit (RAIF) in the INTCON register (Register 2-3).'

    The following tip is the last I can give. The next step is to write the program for you!

    Read the port before enabling the interupt!!!

    Regards,
    Bob
    Come on! I know i sound stupid but i am not.
    i DO read porta bits individually prior to enabling intcon, even if i maybe didn't mention it.
    the int occurs anyway. when i outout the state of porta at the begining of interrupt routine 2 strange things can be noticed. it seems it is ra3 that triggers the interrupt. however i used the same program structure for another project and i didn'have such problem. even if the ra3 was left floating.
    second thing: porta.5 value is not what it is supposed to be. with no wpu and set low with trisa, it is high when interrupt occurs. dammit.

    the complete source code is at:
    http://users.edpnet.be/charlesetchri...g/se210308.pbp

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts