Code entering endless loop


Results 1 to 12 of 12

Threaded View

  1. #5
    Blackhawk's Avatar
    Blackhawk Guest


    Did you find this post helpful? Yes | No

    Default

    I haven't got a digital version of the circuit diagram, but I can tell you that there is a pull up resistor on MCLR. The input lines will eventually be toggled by another micro so right now they don't have pull down resistors, I suspected residual charge on the pins before so I tried rigging up a pull down resistor (just loosely) and it didn't appear to help, I should try it again properly to make sure however.

    EDIT: for reference here is the whole program

    Code:
    ' Porta-0 = Y acceleration     $81 then $85
    ' Porta-1 = X acceleration     $89 then $8D
    ' Porta-2 = Pressure           $91 then $95
    ' Portb-0 = Arm input
    ' Portb-1 = Machdelay input
    ' Portb-2 = Apogee charge
    ' Portb-3 = Main charge
    ' Portb-4 = Buzzer
    
    Symbol  PortB = 6       'PortB is register 6
    Symbol  TrisB = $86     'PortB data direction is register hexadecimal 86
    symbol  ANSEL = $9B     'Analogue select port
    Symbol  ADCON0 = $1F    'Analogue control port 0
    Symbol  ADCON1 = $9F    'Analogue control port 1
    symbol  ADRESH = $1E    'Analogue result register high
    Symbol  ADRESL = $9E    'Analogue result register low
    poke ANSEL , $F
    poke ADCON0 , $80
    poke ADCON1 , $80
    Poke TrisB , 0
    B5 = 1
    
    start:  poke ADCON0 , $91
            pause 1
            poke ADCON0 , $95
            pause 5
            peek ADRESH,B0
            Peek ADRESL,B1
            W6 = W0
            W0 = W0 - 50
            peek PortB, B2
            B3 = B2 & 1
            B4 = B2 & 2
            if B3 = 1 then beep
            if B4 = 2 then delay
            goto start
            
    delay:  B5 = B5 + 2
            high 4
            pause 1000
            low 4
            pause 1000
            high 4
            pause 1000
            low 4
            B4 = 0
            goto start
            
    beep:   high 4
            pause 5000
            low 4
            goto armed
            
    armed:  poke ADCON0 , $89
            pause 1
            poke ADCON0 , $8D
            pause 5
            peek ADRESH,B6
            Peek ADRESL,B7
            if W3 < 300 then machdelay
            goto armed
            
    machdelay:  for B8 = 1 to B5
                pause 5000
                next B8
                goto launched
                
    launched:   poke ADCON0 , $91
                pause 1
                poke ADCON0 , $95
                pause 5
                peek ADRESH,B6
                Peek ADRESL,B7
                W6 = W6 + 10
                if W3 < W6 then apogee
                W6 = W3
                goto launched
                
    apogee: high 4
            pause 5000
            low 4
            high 2
            pause 5000
            low 2
            goto falling
            
    falling:    poke ADCON0 , $91
                pause 1
                poke ADCON0 , $95
                pause 5
                peek ADRESH,B6
                Peek ADRESL,B7
                if W3 > W0 then main
                goto falling
                
    main:   high 4
            pause 5000
            low 4
            high 3
            pause 5000
            low 3
            end
    Actually just looking back over what I posted, I poke portB to all outputs at the start, could this be causing the problems I'm seeing?
    Last edited by Blackhawk; - 25th November 2006 at 15:34.

Similar Threads

  1. Help with Pic Delay Pulse code please
    By g7jiq in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 17th April 2009, 19:19
  2. Help with Pic Delay code mod please
    By g7jiq in forum General
    Replies: 1
    Last Post: - 26th March 2009, 01:06
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  4. Help with LCD commands with button I/P
    By g7jiq in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 9th January 2008, 11:57
  5. help optimising code
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th March 2007, 11:27

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