Inicializing to Interrupt World


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2012
    Posts
    18

    Default Inicializing to Interrupt World

    Hello Everyone,

    I'm trying to inicialize in programming with interrupts.

    I've read lots of posts and try to adapt my way.

    Here is my sample code (PIC 16F628A):

    Test1:
    Pause 500 ' Wait for LCD to startup
    Lcdout $FE, 1, "Test" ' Clear LCD screen

    Sleep:
    TrisB = %01000001
    OPTION_REG.7=0
    OPTION_REG.6=0 'Trig on falling

    INTCON.1 = 0
    INTCON.4 = 1

    @ SLEEP
    @ NOP
    @ NOP
    PAUSE 500

    Lcdout $FE, 1, " Wakeup" ' Clear LCD screen
    pause 1500
    goto Test1


    The program display "Test" and wait. After RB0 interrupt occurs, the display will change to "Wakeup" and after 1,5 sec. it display again "Test" and wait once more for RB0 interrupt.

    The interrupt RB0 works fine the first time, but after that enters in sleep mode and never get out of sleep.

    Could anyone help me out?

    Thanks,
    Nuno

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Inicializing to Interrupt World

    I think you need to read portb after you awake from sleep to clear the mismatch.

    At the top
    Code:
    Dummy var Byte
    Place this after your sleep command
    Code:
    Dummy = PORTB
    Last edited by mark_s; - 23rd November 2015 at 15:56.

  3. #3
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: Inicializing to Interrupt World

    Hello Mark and thanks for your answer, but it doesn't work...

    It happens the same thing, enter the first time, and after that, never enter in sleep again.

    I include the "On interrupt goto..." . In this case, the first time it works as expected, but after wakeup the first time, enter in loop in subprogram "Wakeup".

    If anyone coul help, i'm lost...

    Thanks,
    Nuno

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Inicializing to Interrupt World

    Hi

    I dug up some old code I did on a pic16f819. Maybe it will help? I did not see Intcon.7 set in your code?

    Place this above your variable declaration
    Code:
    OPTION_REG.6 = 0        'INTERUPT PORTB.0 ON 1 = RISING EDGE 0 = falling
    INTCON.4 = 1            'ENABLE RBO INTERUPT
    Sleep
    Code:
    SLEEPLOOP:
        'OPTION_REG.7 = 0        'ENABLE PULLUP RESISTORS PORTB
        INTCON.7 = 1    'ENABLE GLOBLE INTERUPTS
    @ SLEEP             ;ASSEMBLY SLEEP COMMAND - TURNOFF uP CLOCK
    
        INTCON.7 = 0    'ON INTERUPT DISABLE GLOBLE INTERUPTS
        INTCON.1 = 0    'RESET INTERUPT FLAG

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Inicializing to Interrupt World

    I don’t know how PBP interrupts work, but yes you do have to clear the interrupt flag.
    Code:
    if INTCON.1 = 1	then		' check if portb.0 interrupt occurred
    ‘ do the thing you wanted portb.0 interrupt to make happen
    INTCON.1 = 0			' clear portb.0 interrupt flag
    endif
    This is in a case where the interrupt could have been triggered by more than one event.
    Last edited by Art; - 24th November 2015 at 19:03.

  6. #6
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: Inicializing to Interrupt World

    Thanks everyone.

    The major problem, was a pull down button RB0, that was not working correctly.

    Thanks,
    Nuno

Similar Threads

  1. Hello World help please 18F14K50 config
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th August 2011, 18:35
  2. Welcome into PIC world
    By shafi008 in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 29th April 2009, 07:51
  3. Remote Control World !
    By iugmoh in forum General
    Replies: 4
    Last Post: - 23rd April 2008, 00:03
  4. (noob)hello world?
    By m4gill4 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 30th November 2007, 01:23
  5. wired world
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th February 2007, 17:23

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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