Getting Stuck in loop


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    The complete code is pretty long.... but here are the settings I am using. The code I posted prior is first few lines I have to run in the code. After that is is just decoding the data so I can send it to a display. The 3 8-bits of data that I read from PortJ are characters that used to be sent to a 16segment display, which I am working to replace with a modern dot-matrix dispaly.

    Code:
    ' Genenal Register Settings, Port Settings and System Definitions
    
    
    
    CMCON = 7								' Disables the Comparitor Pins
    ADCON1 = 15								' Disables the A/D Converter Pins
    TRISA = $FF							' Define Port A(0-7) as Input 
    										'      (Host TTL inputs, RA7 unused) 
    TRISB = $E0								' Define Port B(0-4) as Output
    										'      (RB0-4 Character Output; RB5-7 are programming port)                                                 
    TRISC = $00								' Define Port C(0-2) as Outputs 
    										'      (Left=C0; Middle=C1; Right=C2 displays)
    TRISD = $00								' Define Port D(0-7) as Output 
    										'      (Character Data Outputs)
    TRISE = $FF								' Define Port E(0-7) as Inputs 
    										'      (Ext. Keyboard Inputs)
    TRISF = $F0						' Define Port F(0-3) as LED Outputs, F(4-5) as 
    										'       Test SW inputs and F(6-7) as Display Int and Kbd Int I/O
    TRISG = $F0								' Define Port G0 as I/O for Reset, G1-3 as Rd/Wr/Fl Outputs
    TRISH = $FF								' Define Port H(0-7) as Inputs
    TRISJ = $FF								' Define Port J(0-7) as Inputs (Host TTL inputs)                        
                                                                             
    Define OSC 20							' Sets Oscillator Speed at 20Mhz
    Define BUTTON_PAUSE 100					' Sets Button Debounce time to 100 ms
    Define I2C_SLOW 1						' Sets I2C Speed to 100KHz

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


    Did you find this post helpful? Yes | No

    Default

    Stuff you want to REPEAT needs to be in between the REPEAT
    UNTIL.

    Like

    REPEAT
    this
    UNTIL this

    Not

    REPEAT
    UNTIL this
    do this
    Regards,

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

  4. #4
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Stuff you want to REPEAT needs to be in between the REPEAT
    UNTIL.

    Like

    REPEAT
    this
    UNTIL this

    Not

    REPEAT
    UNTIL this
    do this
    I am using the repeats as delays so the pic waits for the data basically. The data being sent comes in as 3 seperate 8-bits in sequence. The data is read off of PortJ. The data always comes after PortA.5 goes low. Ant it is always in a specific order. If I miss any 1 of the three I cannot tell what the actuall character is.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    How neat the signal on PORTA.5 is? Where this signal come from?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    How neat the signal on PORTA.5 is? Where this signal come from?
    Looking at the signal in question on an o-scope, It looks pretty clean to me. It is connected to a 100K pull-up to 5V. The transition from high to low does have some ringing , that lasts about 90nS give or take, but the peaks are all < 0, so it should still be seen as a low.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Reduce it!!! Let's say ~1-10K pull-up.

    AND, wait a few Usec after you detect the falling edge...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    1) @20Mhz ... min Pauseus is ... 3µs !!!

    2) UNTIL NOT PortA.5 is much quicker than UNTIL PortA.5 = 0

    3) PortF.6 = 1 is much quicker than HIGH PortF.6

    4) Instead of Repeat - Until NOT PortA.5, try While PortA.5 - Wend ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In fact, you should use LATF.x instead of PORTF.x ...
    Alain, OP says WHILE:WEND didn't work.. not sure why... sounds odd...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by mister_e View Post
    In fact, you should use LATF.x instead of PORTF.x ...
    Alain, OP says WHILE:WEND didn't work.. not sure why... sounds odd...
    a good point for a " not so clean" signal ...

    While PortA.5 : Wend just gives

    BTFSC Porta,5
    GOTO $-1

    ...

    asm is really useful, sometimes !!! lol

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  11. #11
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    1) @20Mhz ... min Pauseus is ... 3µs !!!

    2) UNTIL NOT PortA.5 is much quicker than UNTIL PortA.5 = 0

    3) PortF.6 = 1 is much quicker than HIGH PortF.6

    4) Instead of Repeat - Until NOT PortA.5, try While PortA.5 - Wend ...

    Alain
    Couple of things... My code as it is shown works for the most part as long as the loop does not get hung up.


    1) Made the change, seems to work as before....

    2) Made change code works as it did before

    3) I will randomly miss characters, changed it back to what I originally had

    4) Made change, I no not get any characters.

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