Help Quick Need to make code smaller


Results 1 to 40 of 42

Threaded View

  1. #3
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: Help Quick Need to make code smaller

    Couldn't edit my last post for some reason - so here's another idea to try:

    Where you have some code like this:

    SW10:
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000
    Pause 500
    PulsOut PORTA.2, 50000

    You could try this:

    CounterA VAR BYTE

    FOR CounterA = 0 TO 9
    PulsOut PORTA.2, 50000
    Pause 500
    NEXT CounterA

    Or get rid of the PULSEOUT as mentioned above.
    Starting the FOR...NEXT loop at 0 instead of 1 saves a bit of space too.

    >>>>
    Also, you could set up the loop in a sub-routine, then just load a CounterStop value:

    CounterStop VAR BYTE

    ; Your code sets a loop amount here.
    CounterStop = 5 ; Or whatever amount of loops you want

    GoSUB HornLoops

    Horn_Loops:
    FOR CounterA = 1 TO CounterStop
    PulsOut PORTA.2, 50000
    Pause 500
    NEXT CounterA
    RETURN


    Arch
    Last edited by Archilochus; - 16th January 2005 at 19:20.

Similar Threads

  1. Code doesn't work on 16F648A
    By Mr_Joe in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2018, 22:09
  2. Cordic trig assembly code for PIC18f
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 54
    Last Post: - 8th September 2015, 05:36
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Replies: 1
    Last Post: - 31st August 2005, 20:00

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