newbe wants to know how many VAR's can you have


Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    15

    Default newbe wants to know how many VAR's can you have

    I have a 16f877 chip and have alot of VAR statements like this. The question is haw many VAR statements can you have in a program. Can I replace all these VAR's and use just one VAR because the values will always be the same for different FOR statements. I have this many of VAR's at the beginning of the program. Thanks, Leon

    a var byte
    b var byte
    c var byte
    d var byte
    e var byte
    f var byte
    g var byte
    h var byte
    i var byte
    j var byte
    k var byte
    l var byte
    m var byte
    n var byte
    o var byte
    p var byte

    I use these like this

    (example)
    for b= 1 to 100
    if b=100 then port1.0

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: newbe wants to know how many VAR's can you have

    Hi,
    The number of variables you can have depends on the amount of RAM in the actual PIC you're using and on the size of the variables you declare (BIT, BYTE, WORD, LONG). For example the 16F877A has 368 bytes of RAM, PBP uses a couple of those for its internal use (~30 or so I think) and the rest is available for you to use. The compiler will throw an error if you're trying to allocate space that aren't available.

    It quite common to have a couple of "general purpose" variables used in FOR-NEXT loops etc. You don't have to have a separate one for each loop but obviously it depends on what it your doing.

    /Henrik.

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