DT interrupts and Pause


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86

    Default DT interrupts and Pause

    Hey guys, I've had great success in my latest project thanks a lot to the info in these forums. I came across an odd problem while using Darrel Taylors interrupts around a Pause command I like to give my power supply time to level out so I usually put a pause 1000 or whatever near the beginning of the code before I do anything that will start to draw power. When I enable the RX_Int before the pause 1000 everything works like I want, however if I place the enable immediately after the Pause 1000, the interrupt does not work. I have already made a type of pause command that acts as a debounce while refreshing my LEDs, which I can use if needed and just refresh with blanks, but found the problem a little curious. If anyone has any knowledge on why or how to clear up whatever I'm doing I would appreciate it.

    Code:
    '*********From Mister_E's calculator**********
    
    RCSTA = $90 'enable serial port and cont rx
    TXSTA = $24 'enable TX, BRGH = 1
    SPBRG = 17  '9600 baud @ -0.03%
    SPBRGH = 4
    BAUDCON.3 = 1   'enable 16 bit baudrate
    '***************************************************
    
    
    ;****************Using Darrel Taylor Interrupts****************************
    ;----[High Priority Interrupts]--------------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler     RX_INT,     _GetData,   PBP,  no
            INT_Handler     TMR0_INT,   _IntCounter, PBP, yes
        endm
        INT_CREATE               ;Creates the High Priority interrupt processor
    ENDASM
    
    T0CON = %11010010       'T0 = 8 bit, Prescaler 8
    
    '@   INT_ENABLE  RX_INT     ; enable RX_INT interrupts
    Pause 1000
    @   INT_ENABLE  RX_INT     ; enable RX_INT interrupts
    
    mainloop:
      
     '...
    
    goto mainloop
    
    '---[USART RX - interrupt handler]---------------------------[High Priority]---
    GetData:
      
        HSERIN 1000,No232,[inbyte]
        hserout [inbyte]
        red = 1         'turn off red LED
        stream[counter] = inbyte
        counter = counter + 1
        if inbyte = 13 then 
            counter = 0
            update = 1
        endif
       
    No232:
    @ INT_RETURN
    
    IntCounter:
    
        ticks0 = 6      'preload to get 200 us
        count200us = count200us + 1
    
    @ INT_RETURN
    I've included the parts I think are relevant as everything works fine or not fine based on which enable line is commented out.

    Thanks
    David

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    By the time it finishes the PAUSE 1000, the USART buffer has probably overflowed.

    Check the OERR bit (RCSTA.1).
    If it's set, you have to toggle the CREN bit (RCSTA.4) to reset the USART.

    Since you are using HSERIN, you can set ....
    DEFINE HSER_CLROERR 1
    But that way, your program will never know when the overflows happen.

    Or, you could just wait to set-up/enable the USART until after the PAUSE.
    <br>
    DT

  3. #3
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    So once the interrupt is setup, is the USART running in the background even when not enabled and that would cause the overflow? I assumed if I disabled the interrupt the USART was basically sitting there inactive. I would have expected the problem to show up when the interrupt was enabled and there was a long pause, but that seems to execute just fine. I'll play with clearing CREN shortly

  4. #4
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    Both solutions worked, it is good to know that everything is running in the background and that the problem is that I'm just not servicing the interrupt to keep the flags clear. I'll have to keep that in mind for next time.

    Thanks, David

Similar Threads

  1. INT2 anomaly in DT_INTS-18??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th February 2010, 20:07
  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. 12F683 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 22nd November 2008, 12:47
  4. Replies: 1
    Last Post: - 1st November 2006, 03:11
  5. too many interrupts
    By trying in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd February 2006, 13:38

Members who have read this thread : 1

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