Initialize variables


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2014
    Posts
    12

    Default Initialize variables

    Hi.
    I use a PIC18F45K80 @ 64MHz.
    I have a seperate pbp file with my LCD menu code, witch I include at the end of my main code.
    In my menu file I declare some variables and initialize them.
    The strange thing is that not all of the variables get initialized so I have to initialize them again.
    Is there anything wrong with the way I initialize the variables?
    For example the variable go_back doesnt get set to 0 the first time.

    Code:
    '************************ VARIABLES *****************************
    
    
    btn_debounce        var byte    :   btn_debounce = 50
    btn_rpt_start_time  var word    :   btn_rpt_start_time = 300
    btn_rpt_time        var byte    :   btn_rpt_time = 100
    show_menu           var byte    :   show_menu = 0
    menu_var            var word    :   menu_var = 0
    menu_var_min        var word    :   menu_var_min = 0
    menu_var_max        var word    :   menu_var_max = 0
    btn_repeat          var bit     :   btn_repeat = 0
    btn_repeat_quick    var bit     :   btn_repeat_quick = 0
    btn_released        var bit     :   btn_released = 0
    go_back             var bit     :   go_back = 0    'THIS INITIALAZATION DOESNT WORK, IT'S INITIALIZED AS 1
    
    
    
    
    '****************************************************************
    '*****************     MENU SUB ROUTINE      ********************
    '****************************************************************
    'menu
    menu:
        go_back = 0    'BUT THIS DO
        while go_back = 0
            select case show_menu
                case 0
                .......
                .......
    Regards
    /Matias

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Initialize variables

    Wild guess, something is writing to the byte/word/whatever this bit is apart of.

    George

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


    Did you find this post helpful? Yes | No

    Default Re: Initialize variables

    oh oh ...

    that looks Basic " C style" written ...

    @first ... try not to initialize variables on the same line as you declare them ... ( one declaration block and further, one initialization block )

    we could suspect the compiler to consider those are not initialization but directives ! let's say it could be a little bug ( not sure at all ... )

    did you try MPLAB SIM to track your initialization sequence ??? ( excellent debugging tool, BTW ... )

    Alain
    Last edited by Acetronics2; - 19th February 2015 at 13:36.
    ************************************************** ***********************
    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 " !!!
    *****************************************

Similar Threads

  1. How can I initialize the EEPROM when programming
    By luxornet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th November 2014, 09:31
  2. SD card does not initialize
    By bushratariq in forum mel PIC BASIC
    Replies: 1
    Last Post: - 21st August 2014, 12:00
  3. Do you have to initialize an on-Screen Display module?
    By Ramius in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th April 2011, 00:53
  4. PortB pins will not initialize LOW, only HIGH?
    By ronbowalker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th December 2009, 19:27
  5. HOW do you initialize PortC to normal I/O??
    By Len in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th June 2005, 18:56

Members who have read this thread : 1

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