Getting Stuck in loop


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Looking at the first post,

    I think this could be the issue here.

    Code:
    X var PORTA.5
    Y var PORTF.6
    
    
    REPEAT
    UNTIL x = 0  ' X = 1 ;  wait until it is 0.
    
    High y       ' Here, X = 0.
    
    while x = 0 : wend  ' Here, X = 0, wait until it is 1.
    
    REPEAT
    UNTIL x = 0  ' X = 1 ;  wait until it is 0. 
            Pauseus 1
    		Location1=PortJ
    
    while x = 0 : wend  ' Here, X = 0, wait until it is 1.
    
    
    REPEAT
    UNTIL x = 0         ' X = 1 ;  wait until it is 0. 
            pauseus 1
    		CharLow=PortJ
    
    while x = 0 : wend  ' Here, X = 0, wait until it is 1.
    
    REPEAT
    UNTIL x = 0
            pauseus 1
    		CharHigh=PortJ
    		
    while x = 0 : wend  ' Here, X = 0, wait until it is 1.

    ------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    sayzer:

    I'll give it a try and see if that helps...

  3. #3
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    sayzer:

    I'll give it a try and see if that helps...
    I made the change and it made no difference at all.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    If these changes made no difference, then you have an issue with your inputs.

    _______________-
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    If these changes made no difference, then you have an issue with your inputs.

    _______________-
    I don't know... the signals on the ports are TTL level, so it is pretty definite if it is a high or low on the port.

    I have been digging around the code, and actually looked at the Assemble that PBP creates. After you work through all the macros and stuff some of the commands are LONG. A while loop command can be well over 20 instructions depending on the logical operator used. This sort of explains why the my code does not work when I use while:wend combinations. 20 instructions on the 18F8722 at 20MHz takes like 4uS to excicute... seeing how the signal I am looking for is only there 1 uS I can see how it will miss it...

  6. #6
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    As you have correctly surmised, trying to detect a 1uS pulse by polling a port pin is not going to be reliable.

    Use an external (or pin change) interrupt instead and you will not miss any of these short pulses.

Similar Threads

  1. Controlsystem for compact sporting (clay shooting)
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2009, 16:48
  2. Avoiding getting stuck in a loop
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2008, 11:41
  3. Serin to Serin2 ??
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2008, 03:56
  4. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  5. Newbie question:
    By Izone in forum mel PIC BASIC
    Replies: 2
    Last Post: - 26th February 2006, 16:24

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