12f675_fuse_about_to_blow!


Results 1 to 40 of 929

Threaded View

  1. #27
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Now that you're aware of how ON INTERRUPT works there are a few things that can be done to help speed up the response (latency). Instead of having a single 500ms long pause, how about 500 pauses, each 1ms long?
    Code:
    i VAR WORD
    Main:
      GPIO.0 = 1
      GOSUB GoToSleep
      GPIO.0=0
      GOSUB GoToSleep
    Goto Main
    
    GoToSleep:
      For i = 1 to 500
        PauseUs 1000     'Tweak this if timing is critical.
      Next
    RETURN
    Now, you should get pretty close to what you expected in the first place. If timing is really critical you'll need to tweak the PauseUs statement as each time thru the loop takes a couple of uS longer due to the inserted checks of the interrupt-flag and the fact that it takes a few cycles to jump around inside the FOR-NEXT loop.

    Also, remember what we said about HIGH and LOW? That they write to the TRIS register everytime.....and there's no need for you to use them as you've so elegantly set the TRIS register correctly at the beginning of your program. It's usually "better" and faster to simply write directly to the port register with GPIO.0=1 etc.

    /Henrik.
    Last edited by HenrikOlsson; - 23rd March 2010 at 18:44.

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