DT Instant Interrupts


Results 1 to 39 of 39

Threaded View

  1. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by krohtech View Post
    Oh, sorry I forgou to mention I am using an 18F PIC. Can I use the timer template -14?
    You're talking about one of my favorite 'staples' whenever I build something...I call it a 'heartbeat'...
    I have an LED connected to a specific pin...
    I set up Timer 0 to run at a decent rate according to my main clock speed...i.e. once per second-ish, 4 times per second-ish, doesn't really matter, as long as I can see it blink.
    Then every Timer 0 overflow, I increment a byte variable, last I set the LED to follow a certain bit of that variable.
    So, say I use 'temp' as my variable.
    myint:
    temp = temp + 1
    led = temp.0 'led will flash on/off every other time thru loop
    resume

    If the LED flashes too fast, I use temp.1, still too fast, maybe temp.2.
    Or, conversely, if I use temp.4, and that flash is too slow, I'll use temp.3, or temp.2, whatever...until I find a flash rate that works for me.

    DT's Fast interrupts and SSPWM code are great pieces of code...but I think they're big time overkill for what you want...

    An example cut from one of my last programs:
    Code:
    'CONFIG statements semi-permanently set in PBP 18F4620 .INC file
    resetplaceholder:	'18f4620 code
    DEFINE OSC 10
    DEFINE NO_CLRWDT 1	'no extra clear watchdog timer instructions
    DISABLE
    CLEAR
    led1 var porta.5
    heartbeat var byte
    startupholder:
    goto skipsubs	'skip over all the commonly used subroutines
    ON INTERRUPT GOTO INTHANDLER
    DISABLE
    INTHANDLER:	if intcon.2 = 1 then			'timer 0 overflow interrupt handler
    			intcon.2 = 0
                           heartbeat = heartbeat + 1
                            led1 = heartbeat.0		'led flash about every ~1.6 seconds
    ' change heartbeat.0 to heartbeat.X where x = 0 - 7 to change heart beat flash rate
    INTFINISH:
    RESUME
    DISABLE
    'end of commonly used subroutines, skipsubs block for setting up registers, lcd, whatever else...
    skipsubs:
    	t0con = $84
            intcon = $e0
            cmcon = 7
            pie2 = $80
            trisa = 0
            porta = 0
            led1 = 0
            output led1
    ' change prescale value in $84 to change flash rate
    ENABLE
    mainloop:
    ' do something useless or useful here
    goto mainloop
    END
    IF you're not using a '4620, then you'll have to figure out which registers need which values as far as interrupt and timer registers go.
    I chose porta.5 because it was available. Change that to what you need also.
    Last edited by skimask; - 9th February 2008 at 06:53. Reason: Removed runny colons....nya nya... :D

Similar Threads

  1. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  2. DT Instant Interrupts help
    By perides in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 26th November 2008, 18:41
  3. 12F683 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 22nd November 2008, 12:47
  4. 18F1220 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th June 2008, 05:37
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

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