Doubt with interrupt on change


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    15

    Default Doubt with interrupt on change

    Well my problem is that i want to make an interrupt on change with RA0 on PIC16F684 but since i'm beginer in this and i'm not a well english reader i have troubles doing this, mi code next:

    [B]inicio:
    if INTCON.0 = 0 THEN disparo
    GOTO inicio

    disparo:
    PORTA.0 = 1
    INTCON.0 = 0
    FREQOUT PORTC.5,10,38000
    PORTC.5 = 0
    RONDAS = RONDAS - 1
    GOTO inicio[\B]

    if somebody can help me, i'd be very glad. Thanks

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi lugo.p,
    Let's start off with, change the big old Capital B to the word code, then your code tag will work, do it on both ends.

    Add this to your code along with the proper configs and define your OSC.


    Code:
    ON INTERRUPT GoTo disparo
    INTCON = %10001001
    'Bit 0 = RAIF      Port A Interrupt Flag
    'Bit 1 = INTF      INT Flag
    'Bit 2 = T0IF      Timer zero Interrupt Flag
    'Bit 3 = RAIE      Port A Interrupt ENABLE
    'Bit 4 = INTE      INT Enable
    'Bit 5 = T0IE      Timer zero Interrupt Enable
    'Bit 6 = PEIE      Peripheral Interrupt Enable
    'Bit 7 = GIE       Global Interrupt Enable
    
    IOCA = %00000001   ' enable IOC on RA0
    'Bit 0 = RA0 interrupt on change
    'Bit 1 = RA1   "   "    "   " "
    'Bit 2 = RA2   "   "    "   " "
    'Bit 3 = RA3   "   "    "   " "
    'Bit 4 = RA4   "   "    "   " "
    'Bit 5 = RA5   "   "    "   " "
    'Bit 6 = Unimplemented
    'Bit 7 = Unimplemented
    
    OPTION_REG = %00000000
    'Bit 0 = PS     Prescaler
    'Bit 1 = PS     Prescaler
    'Bit 2 = PS     Prescaler
    'Bit 3 = PSA    Prescaler Assignment bit
    'Bit 4 = T0SE   Timer zero source edge select bit
    'Bit 5 = T0CS   Timer zero clock source select bit
    'Bit 6 = INTEDG Interrupt Edge Select bit
    'Bit 7 = RAPU   PortA weak pullup bit
    Last edited by Archangel; - 5th March 2010 at 04:32.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Feb 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    And puting that on my code IOC will work?

    Because i have configured IOCA = $01, OPTION_REG = $00 and INTCON = $98
    Last edited by lugo.p; - 5th March 2010 at 15:26. Reason: Error

Similar Threads

  1. A Simple IOC Routine (Interrupt On Change)
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th March 2010, 19:53
  2. 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
  3. 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
  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 : 1

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