DT Instant Interrupts - Clarification?


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Hi All,

    I am pleased to announce that the external interrupt routine is now working properly. Thank you to all who have helped me resolve my problems - much appreciated

    To aid in my PCB layout I would like to move my ADC channels to AN1 and AN2. This will mean that I need to alter the type of interrupt from an external interrupt on GP2 to a Change on Interrupt on GP4. To do this I have changed the Interrupt Handler in DT_INST-14 from INT_INT to GPC_INT, Enable GPC_INT and enabled bit 4 of the Interrupt-On-Change GPIO Register (ie IOC.4=1). My interrupt switch is set up with a 10k pull-up resistor from GP4 to +5V and a momentary action switch from GP4 to 0V. The code compiles without error but the change on interrupt function does not work in "the real world".

    I would have thought this was a pretty straight forward change but I am obviously missing something important. Would someone please direct me to where I have gone wrong?

    Cheers
    Barry

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Hi Barry,
    In your latest attached code you have the line
    Code:
    ANSEL = %01011010       ' Set Fosc/16
    Which sets GPIO.4/AN3 to analog mode. Try changing it to digital if you haven't already done that.

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Hi Henrik,

    Yes, I had already changed the ANSEL register
    I had changed the TRISIO register too.
    Attached is my full code listing for reference.

    Now what? I am sure it is only something simple but I just can't figure it out...PICSprayer.bas

    Cheers
    Barry

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    [ code] remove the spaces in the brackets [ /code]
    Code:
     remove the spaces in the brackets
    It will save folks from having to download your code to look at it.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Unless I am not following your changes right, It seems in your ISR you are still waiting while gpio.2 is high. since that is now an analog input (I think) it might just be zooming right through the ISR making it look as though it was never called.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Yes, it was the GPOI.2 statement in the ISR that was causing the problem.
    All fixed now

    Code:
    This is a Code Space Test
    Hey, I even got the code space thing happening - I'm on fire!!!

    Thanks for all your help guys - really appreciate it.
    I will post details of the final project once it is all up and running - code, circuit diagram, PCB and some pretty pictures of the finished product.

    Cheers
    Barry

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    Just continuing on from this thread i have my own question about DT Interrupts for the 12F683.

    Having looked at the example given by darrell for the generic timer the code below seems unecessary if we know what the values are for the prescaler etc?

    Code:
    ;---[TMR1 reload - interrupt handler]-----------------------------------------
    ASM ; Calculate Timer Reload Constant
    ReloadInst = 8; # of Intructions used to reload timer
    if ((Prescaler == 1)||(Prescaler == 2)||(Prescaler == 4)||(Prescaler == 8))
    MaxCount = 65536 + (ReloadInst / Prescaler)
    TimerReload = MaxCount - (OSC*1000000/4/Prescaler/Freq)
    if ((TimerReload < 0) || (TimerReload > (65535-ReloadInst)))
    error Invalid Timer Values - check "OSC", "Freq" and "Prescaler"
    endif
    else
    error Invalid Prescaler
    endif
    ENDASM
    
    Do we need this error checking if we know and are happy with osc/prescaler/freq etc or am i missing something else. It looks like it might take a fair bit of code space?

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


    Did you find this post helpful? Yes | No

    Default Re: DT Instant Interrupts - Clarification?

    That snip perform calculations at compilation time and doesn't take ANY codespace. 'course you can remove it. It's there for convenience and ease of use.
    Steve

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

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