PIC18F1220 - Variables initialisation placement makes a change


Results 1 to 8 of 8

Threaded View

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


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1220 - Variables initialisation placement makes a change

    Further, variables aren't automatically initialized (ie set to a specific value).

    Where in your code you put the declaration of the variable can change the ORDER of the variables in RAM so if, like Charlie says, you're somewhere writing outside of an array it's possible that the order in which the variables are declared makes important variables get corrupted in one case and not so important varaibles get corrupted in the other. In either case you have a potential problem that you need to find - provided that IS indeed what's happening of course.

    For example
    Code:
    SMS VAR BYTE 160
    Index VAR BYTE
    SMS[160] = "A"
    Classic error there, arrays are zero indexed so the last element of the SMS array is SMS[159]. In this case Index will be assigned the value "A" because Index is declared right after the SMS array. Now, that might not ALWAYS be the case depending on where it all ends up relative to RAM banks and such.

    Try to cut the code down to a minimal that still shows the error and post it.

    /Henrik.
    Last edited by HenrikOlsson; - 18th February 2021 at 14:45.

Similar Threads

  1. Replies: 2
    Last Post: - 14th December 2020, 08:13
  2. SIM908 Initialisation
    By wpkeenan in forum GSM
    Replies: 0
    Last Post: - 22nd May 2014, 00:57
  3. PIC18F1220 locked up
    By eggman in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th April 2011, 15:11
  4. PIC18F1220 RA4 using PULSIN ?
    By Del Tapparo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th June 2009, 00:10
  5. LCD - Blocks at Start-up/Initialisation
    By Rob in forum General
    Replies: 4
    Last Post: - 11th February 2005, 07:36

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