Briefly, maximum number of vars?


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jerson View Post
    Chris,

    I suggest you try loading all your BIG arrays right at the top. Then put all the little single variables like bytes or words or longs after that.
    I've tried this method, it seems to make no difference

    There is another possibility that you need to consider - is there any asm interrupt code of your own that might be disturbing the register banks.
    Regards
    I do have an ASM interrupt.
    In the interrupt I use indirect addressing to load an array (the array in question) with data received from the serial port, before it is transmitted out of the serial port again, trapping the received data for analysis and real-time display.

    Before I give the details, the gotcha here is that the code works fine without these additional unused variables. but once I add a few vars in the declarations, after my own var declarations or before them, the problem occurs. At no time are those additional vars referenced in the program code.

    I have looked at the PBP files and it seems that FSR0 and FSR2 are used by PBP, but not FSR1. To do the indirect addressing I load FSR1 with LFSR 1,_RX_BUFFFER, the address of the 1st byte in the RX_BUFFFER array. Then I use POSTINC1 to put each successive received byte into the buffer. I then _save_ the values for FSR1L and FSR1H, so the next time I need to load the next array element I restore FSR1L and FSR1H with the last values in the interrupt. I actually get the same problem even when I don't save the values for FSR1, which suggests that it is pointless to do that anyway

    What I have not done, is to save the values in FSR1L and FSR1H when the program interrupts, but then I don't see any need because PBP doesn't seem to make any use of FSR1, plus the same code works as expected when I reduce the number of unused variables.

    Chris

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Chris Barron View Post

    I do have an ASM interrupt.
    In the interrupt I use indirect addressing to load an array
    Just for confirmation I have reverted to a previous interrupt routine which does not use indirect addressing, does not access the FSR's at all. The same problem is happening.

    Would someone be able to tell me what is the best way to force PBP to locate my variables in places which I know will all my LONG and WORD arrays to fit on one bank of memory

    Chris

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    There was a thread awhile back where someone was having the same trouble, to many variables. Sounds like this is the same thing.

    Maybe a work around would be to scale things in your code and SDFS by not declaring some of the pins as VARs.

    An example would be in SDFS if you are not using the card detect
    Code:
    SD_CD		Var	PORTB.4	' SD card detect
    SD_CD_TRIS	Var	TRISB.4	' SD card detect direction
    to comment that portion out. Probably some things in your code that could be re-done also???

    Just thoughts.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    BTW, are you using the SDFS from MElabs? The one for FAT16 or the one from Jeremy posted on the forum, SDFS32.

    Maybe seeing your code would help too.
    Dave
    Always wear safety glasses while programming.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    There was a thread awhile back where someone was having the same trouble, to many variables. Sounds like this is the same thing.

    Maybe a work around would be to scale things in your code and SDFS by not declaring some of the pins as VARs.
    Just thoughts.

    I could do that, but I would rather not be limited to a smaller number of variables than I have ram locations for.

    I would post the code, but it's over 40k now. Take out the data tables and it's down to about 28k, so it's still a massive post ! The essence remains the same though.

    I'm using the FAT16 MELabs version of SDFS. If the FAT32 version uses less space and doesn't have the same caveats I would like to try it out, but even after that I still would like to include more variables.

    As I've said, the number of ram variables declared seems to be deciding factor and the problem doesn't seem to be affected by the number of aliases. I might consider declaring some large byte arrays and then declare the current individual byte vars which I am using as aliases of the larger array.

    Chris

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