Critique my code, please.


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Critique my code, please.

    I agree Robert, I wish more people would post schematics, pictures and full code. although I know whats its like if your afraid someone will steal your ideas... but the ideas may have only gotten into the head by being sparked by ideas here. I know there is alot like that for me. So.. share the love people and start posting more Pic's (no pun intended), schematics and code
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default Re: Critique my code, please.

    This seems redundant to me
    Code:
        if PIP = 0 then increment
        if PIP = 1 then display
    increment:
    It could be
    Code:
        if PIP = 1 then display
    increment:
    Another possible improvement would be to consider using an interrupt to capture the change in state of PIP. Without that, you could miss / misread the timing since the code could be updating the display and doing a pause thereby losing time before you poll the PIP pin.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Critique my code, please.

    Hi,
    Just a quick note
    Code:
    CNT = CNT + 1
    IF CNT > 65535 then ' This adds a overload catch so it doesnt run away.
    CNT = 0
    goto no_data2
    ENDIF
    The above doesn't really work because CNT is declared as a WORD and can not contain values larger than 65535. The IF statement will never evaluate true so the program will never jump to no_data2. Once CNT is incremented "beyond" 65535 it will automatically wrap around to 0.

    /Henrik.

  4. #4
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: Critique my code, please.

    Correct way to do that is:
    Code:
    CNT = CNT + 1
    IF CNT =0 then ' This adds a overload catch so it doesnt run away.
        CNT = 0
        goto no_data2
    ENDIF

Similar Threads

  1. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 21:44
  2. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 20:51

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