uC Hangs after second serout command


Closed Thread
Results 1 to 11 of 11

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    Hi,
    At first look I'd say you need to change the RETURN to something like GOTO Main.

    /Henrik.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    Why does the uC only runs this code one time. It does not loops it:
    Are you stating that because the status led is always on?

    If this is the case, take note that you turn off the status led only in the subroutine CHECK_DATA and there is no gosub to this sub in your code.

    Cheers

    Al.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    Hi I take notice off that.

    There are more strange things:

    After the:

    SEROUT2 XBEE_TX,84, ["Nieuwe kaart",13,10]

    The uC starts at INIT again and does not go back to the main routine.

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 17-8-2011                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    Include     "modedefs.bas"
    
    Define  OSC             20
    
    STATUSLED           VAR         PORTC.4             ' Rode LED
    BUZZER              VAR         PORTC.7             ' Buzzer
    ReedContact         VAr         PORTC.0             ' Reed contact voor starten dot
    Power_On            VAR         PORTC.1             ' Overname contact power
    Power_XBEE          VAR         PORTB.0
    Power_RFID          VAR         PORTB.3
    
    XBEE_RX             VAR         PORTB.2             ' Serial data vanaf XBEE
    XBEE_TX             VAR         PORTB.1             ' Serial data naar XBEE 
    
    RFID_RX             VAR         PORTB.7             ' Seriele data vanaf de RFID lezer
    RFID_TX             VAR         PORTB.5             ' Seriele data naar de RFID lezer
    
    Card_Temp           VAR         BYTE[4]             ' Temp serie nummer kaart
    
    i                   VAr         BYTE                ' Globale teller
    
    received_date       VAR         BYTE[16]  
    read_try            var         byte                ' Pogin tot lezen
    
    
    x                   var         BYTE[20]
    y                   VAR         BYTE
    
    CRC                 VAR         BYTE                ' CRC over RFID data
    CRC_TOT             VAR         BYTE                ' CRC over totale data
    
    '===============================================================================
    ' Init
    '===============================================================================
    Init:
    
        high Power_On
        
        high Power_XBEE  
        
    
        for x  = 0 to 30
            serout2 XBEE_TX,84,["X2 = ",#x,13,10]    '9600 inverted     
            pause 500
    
        next x    
        
    Goto Main
    
    '*******************************************************************************
    ' Main:
    '*******************************************************************************
    Main:
    
        high Power_RFID
        High STATUSLED
        
        Serout2 RFID_TX,16416,[$AA,$BB,$02,$20,$22]             ' Read Card Command
        
        SERIN2 RFID_RX,16416,100,Check_data,[received_date[0]]    ' Receive data
    
        FOR i = 1 to 8
            SERIN2 RFID_RX,16416,10,Check_Data,[received_date[i]]
        NEXT i
            
        
    Goto Main  
    
    '*******************************************************************************
    ' Check_Data:
    ' 1. Controle op gelezen data
    ' 2. Controle of kaart anders is dan vorige keer
    ' 3. Indien nieuwe kaart schrijf deze in Temp Card Data
    '*******************************************************************************
    Check_Data:
      
        CRC = received_date[2] ^ received_date[3] ^ received_date[4] ^ received_date[5] ^ received_date[6] ^ received_date[7]
        
        If (received_date[0] = $AA) AND (received_date[1] = $BB) AND (received_date[2] = $06) AND (received_date[8] = CRC) Then
            serout2 XBEE_TX,84,["Geldige kaart gelezen CRC := ", HEX2 CRC,13,10] 
       
            ' Controleer of de kaart anders is dan de vorige kaart
            
            If (received_date[4] <> Card_Temp[4]) OR (received_date[5] <> Card_Temp[5]) OR (received_date[6] <> Card_Temp[6]) OR (received_date[7] <> Card_Temp[7]) Then
                SEROUT2 XBEE_TX,84, ["Nieuwe kaart",13,10] 
               
                For i = 4 to 7
                    Card_Temp[i] = received_date[I]            
                NEXT I   
        
                RETURN 
                
            ELSE
                SEROUT2 XBEE_TX,84, ["Oude kaart",13,10] 
                RETURN 
        
            ENDIF    
    
    
    
        ELSE
           
            serout2 XBEE_TX,84,["Ongeldige / geen kaart gelezen",13,10]
            
        ENDIF      
        
    Goto Main

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


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    In Check_Data you have RETURNs, but you're not using GOSUBs to get there, so replace the RETURNs with GOTOs to get back.
    Regards,

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

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    Funny in 2.47 version of the compiler the timeout lable works with returns
    I see that 3.00 does not accept the return.

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


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    As far as I know, the timeout/label option has always used a GOTO to get to the label after the timeout period has expired. I can't say why it would have worked on an earlier version. Maybe luck...
    Last edited by Bruce; - 17th August 2011 at 15:23.
    Regards,

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

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: uC Hangs after second serout command

    time out....go sit on the bench,
    timeout only needed for serin !

    don
    amgen

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