Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Any obvious reason why this program takes over 10 seconds to start up on a PIC 18F4550?

    If I comment out the Interrupt settings at the top (includes and asm) and the ReceiveUSART handler further below, it takes less than 2 seconds.

    Robert
    Attached Files Attached Files
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default

    Not sure about this, but gotta start somewhere.

    The RX_INT is being ENABLEd before the USART registers are set-up. Or, more accurately, since HSERIN/OUT are used in the program, PBP initializes the USART first, then RX_INT is enabled, then the USART registers are changed.

    It may be causing a false interrupt that sends it to the ReceiveUSART: handler, which is expecting to see 2 bytes being received, that were never sent. So it sits there.

    Try using this...
    Code:
    DEFINE HSER_CLROERR 1  ' Hser clear overflow automatically 
    DEFINE HSER_RCSTA 90h  ' Hser receive status init 
    DEFINE HSER_TXSTA 24h  ' Hser transmit status init 
    DEFINE HSER_SPBRG 0    ' Hser spbrg init 
    
    While PIR1.5 = 1     ; clear the buffer
        HSERIN [varByte]
    Wend
    
    @ INT_ENABLE  RX_INT     ; enable RX interrupts
    In place of..
    Code:
    @ INT_ENABLE  RX_INT     ; enable RX interrupts
    
    
    DEFINE  HSER_SPBRG  0               ' 1250 KBAUD @ 20 MHz (CPU)
    
            BAUDCON.3 = 0               ' BRG16 Select 8 bit baud rate generator
    
            TXSTA.5 = 1                 ' TXEN  Enable USART transmitter
            TXSTA.4 = 0                 ' SYNC  Asynchronous communication
            TXSTA.2 = 1                 ' BRGH  High speed baud rate
    
            RCSTA.7 = 1                 ' SPEN  Enable USART receiver
            RCSTA.4 = 1                 ' CREN  Enable continuous receive
    DT

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    Nope, wasn't it. But as I was putzing around trying other stuff I noticed a few attempts were within 2 seconds, but for no apparent reason. For some reason it appeared to be an unstable setup and I remembered that unset pins can do this. And that's when I remembered this from page 235 of the 18F4550:

    -----------------------------------------------------------------------
    The pins of the Enhanced USART are multiplexed with
    PORTC. In order to configure RC6/TX/CK and
    RC7/RX/DT/SDO as a USART:
    • bit SPEN (RCSTA<7>) must be set (= 1)
    • bit TRISC<7> must be set (= 1)
    • bit TRISC<6> must be cleared (= 0) for
    Asynchronous and Synchronous Master modes
    or set (= 1) for Synchronous Slave mode
    -----------------------------------------------------------------------

    I had ignored this paragraph 'cause I had never seen a need for these resistors, I thought it was only for the Enhanced USART. So I added the 4K7 resistors on TX (pulldown) and RX (pullup) and everything works fine, even with my old code.

    Thanks D!

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    Well, I misunderstood what I was supposed to do but when I removed the resistors and put in the TRIS statements it took 9 seconds again. So I set the port pins to 0, same thing, I set them to 1, same thing.

    It works properly with just the 4K7 resistors.

    EDIT: I tried pulling both pins down and that works as well.

    Robert
    Last edited by Demon; - 23rd July 2006 at 16:34.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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