Interrupts on 18F4220


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    2

    Unhappy Interrupts on 18F4220

    Thanks for any help on this--I am new to PICs but cut my teeth some on stamp things....


    I am having trouble getting a simple interrupt routine to run on an 18F4220. (I have some boards that we made earlier that I would like to reuse)

    I started by using a sippet of code from Chuck Hellebuyck (Nuts and Volts June 2006) and a PIC 16F877

    Circuit Stuff (on Protoboard)
    LED on Pin PORTB.1
    Switch on RB0
    ISP for programming

    My Version of his code

    LED1 Var PortB.1

    On Interrupt goto myint
    OPTION_REG = %00111111
    INTCON = %10010000

    loop:
    High LED1
    Pause 100
    Low LED1
    Pause 100
    Goto loop

    DISABLE
    myint:
    Low LED1
    Pause 500
    INTCON.1=0
    Resume
    Enable

    This runs fine on the 16F877 , When I swap in the 18F4220 and change the code to :

    LED1 Var PortB.1

    On Interrupt goto myint
    INTCON2 = %00111111 '<---------change here
    INTCON = %10010000

    loop:
    High LED1
    Pause 100
    Low LED1
    Pause 100
    Goto loop

    DISABLE
    myint:
    Low LED1
    Pause 500
    INTCON.1=0
    Resume
    Enable


    I never get the interrupt routine to run.

    Any Ideas?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PORTB have some analog stuff multiplexed with..
    you need to add
    Code:
    ADCON1=$0F
    at the top of your code to disable ADCs.

    BUT you could also edit the config fuses as well.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Smile Interrupts on 18F4220

    Thanks!!!!

    I made the changes this morning and the 18F4220 is getting the interrupt.

    Thanks for the pointer. I am still learning about the config bits and often forget to look at them.

    I still have a little clock speed issue, but I think that is probably config bits also.....

    Thanks again.

Similar Threads

  1. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. Microcode studio - PIC16F877A Interrupts
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th January 2009, 06:10
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  5. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10

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