USART Interrupt + Pause


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default USART Interrupt + Pause

    I know first hand that placing the Pause command in any code causes the interrupt service to not respond during the pause.

    The problem I have is in a number of places in my code I want to stop to do something for say 500ms. For example an LED would light for 500ms or a timeout in a sub would occur after 30 seconds.

    I'm left scratching my head on how to do this. Although pause is easy and works because this device is a node I want the host PC to be able to communicate with it whenever it wants.

    Am I expect too much? What would be a good approach?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    For immediate response to interrupts - use assembler interrupts.

    For BASIC interrupts with a faster interrupt response time, break down
    your pause times into smaller increments in a loop.

    Instead of PAUSE 500 ' <-- 500mS delay before interrupt service

    X VAR WORD

    FOR X = 1 to 20000 ' ~500mS total
    PAUSEUS 25 ' <-- 25uS delay before interrupt service
    NEXT X

    Just take into account that the time spent in your interrupt handler will add
    to the overall time delay in your loop if the interrupt happens while in a delay
    loop.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    I want to stay out of ASM as much as possible That is, after all, the reason I use PicBasic and not ASM.

    I had contemplated using shorter and more frequent Pause times. I will go that route. The actual times are not huge in this case, they just need to be close enough.

    Thanks Bruce!

Similar Threads

  1. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  2. Replies: 11
    Last Post: - 12th July 2008, 02:36
  3. Fade out LEDs question
    By Sam in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd June 2008, 10:50
  4. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 03:46

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