Instant Interrupts - Revisited


Results 1 to 40 of 773

Threaded View

  1. #9
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default On Change style Int with RB0

    Hi,

    I hope this is the right place to grab your attention. I am using a 16F73 @ 20Mhz with Hardware USART @ 115Kbps. I am using RB0 external interrupt portb.0 (can't help it only it is available) . Initially it is set to fire interrupt on a Low2High edge. Now when inside the interrupt I want to toggle the INT edge bit in the option_reg to have an interrupt on High2Low edge. The simple idea is to reset a timer when a variable duty cycle pulse begin and read the timer value when it turns off. Can't sit in a tight loop to watch if portb.0 = 0 cause got other tasks to do. So I am using Darrel's INT in both ASM and PBP. Here is the code:

    Code:
    ASM
    INT_LIST macro   ; IntSource,  Label,         Type,  ResetFlag?
        INT_Handler  INT_INT,     INT_ASM,        ASM,   NO
        INT_Handler  INT_INT,     _INT_PBP,        PBP,   YES    
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM    
    
    ; BELOW IS THE ASM INTERRUPT HANDLER
    ASM
    INT_ASM
           BSF   STATUS, RP0             ; SELECT BANK 1
           BTFSS OPTION_REG, INTEDG      ; CHECK THE INTERRUPT EDGE
           GOTO  EDGE_LOW
    
    ; IF HERE THEN EDGE IS HIGH2LOW AND INT OCCURED AND NEEDS TO BE ALTERED/////////
    EDGE_HIGH
           BCF   OPTION_REG, INTEDG      ; SET TO INTERRUPT ON LOW2HIGH TRANSITION
           CLRF  STATUS                  ; SELECT BANK0
           CLRF  TMR0                    ; CLEAR TIMER0
           BSF   _HIGH_EDGE              ; SET FLAG THAT THIS IS A LOW2HIGH_EDGE INT
           INT_RETURN                    ; RETURN FROM THE ASM INTERRUPT
    ; IF HERE THEN EDGE IS LOW2HIGH AND INT OCCURED AND NEEDS TO BE ALTERED ////////       
    EDGE_LOW       
            ; BANK1 IS ALREADY SELECTED
           BSF   OPTION_REG, INTEDG      ; SET TO INTERRUPT ON LOW
           CLRF  STATUS                  ; SELECT BANK0
           MOVF  TMR0, 0                 ; MOVE TIMER0 TO W
           MOVWF _TIMER                  ; MOVE TO THE TIMER VARIABLE IN BANK 0
           BCF   _HIGH_EDGE              ; SET FLAG THAT THIS IS HIGH2LOW_EDGE INT
           INT_RETURN                    ; RETURN FROM THE ASM INTERRUPT
    ENDASM
    
    INT_PBP:                     '  PBP INTERRUPT HANDLER
    IF HIGH_EDGE = 1 THEN        '
    HSEROUT [10,"L2H",10]        '
    @ INT_RETURN                 ; RETURN FROM INSTANT INTERRUPT
    ELSE
    HSEROUT [10,"H2L",#TIMER, 10]
    ENDIF
    @ INT_RETURN                 ; RETURN FROM INSTANT INTERRUPT
    Now my questions are :

    1. Will this work ? Chances of false interrupt should not be, cause anyway while changing the option_reg the INT0 flag is not cleared and taken care of in the next PBP slice. Am I right ?

    2. Should I manually check the transmit buffert (TRMT) and do the transmission to make things faster or let it be handled by PBP (keeps my hairfall under control )

    P.S. : Actually I am counting on the email notification and everybody working with Darrel's II . Lester/Darrel please move this thread if you think that this should go as a new thread.
    Last edited by sougata; - 13th March 2007 at 18:26.
    Regards

    Sougata

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 5

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