Counter bigger than a var word/65K - overflow


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    25

    Question Counter bigger than a var word/65K - overflow

    hello "smart people" :-)
    i need a var that counts over the 65k limit of the var word and save it to the internal EEPROM of the uC, is there an "elegant way"/smart way of coding it than using and additional var word that increments everytime the main counter var word gets overflow ?

    thanks in advance for any info/trick :-)

  2. #2
    p5taylor's Avatar
    p5taylor Guest


    Did you find this post helpful? Yes | No

    Default count bigger than 65k word

    Hi jorge did you solve the problem at the thread listed below as i have the same problem any help greatly recieved thanks

    http://www.picbasic.co.uk/forum/show...hlight=COUNTER

  3. #3
    Join Date
    Dec 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    hi
    maybe you could have two word sized varables say Cnt_a and Cnt_b
    when Cnt_a hits 65536 increment Cnt_b ,clear Cnt_a and start counting again
    Cnt_b is the number of times you reached 65K add Cnt_a gives you the Total
    count.

  4. #4
    boboco's Avatar
    boboco Guest


    Did you find this post helpful? Yes | No

    Smile

    Hi,

    as Tony says, word Cnt-A wrap-around to count up Cnt-B once.

    A simple method as example;



    IF newcount then Flag = 0 'Flag to prevent first count setting B

    WHILE countup 'As long as counting is required

    WHILE Cnt-A > 0 AND Flag = 1 'Counting in progress

    Cnt-A = Cnt-A + 1 ' Count operation for A

    Flag = 1

    WEND

    Cnt-B = Cnt-B + 1


    WEND




    in eeprom simply:

    WRITE 0, Cnt-A.byte1
    WRITE 1, Cnt-A.byte0
    WRITE 2, Cnt-B.byte1
    WRITE 3, Cnt-B.byte0


    Hope it helps,

    Rob

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. Puzzling issue with I2CWRITE to 24LC512
    By aberco in forum General
    Replies: 4
    Last Post: - 22nd August 2008, 17:47
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47
  5. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54

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