Help Quick Need to make code smaller


Closed Thread
Results 1 to 40 of 42

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you can still save codespace using the following... but this imply to modify your circuit too. It will gives you pulses from 0-15 depending on the PORTB<3:0> binary representation

    Code:
    DEFINE OSC 4
    
    TRISB = %11111111
    TRISA=%11111011
    
    MaskFromPORTB   var byte
    AmountOfPulsout var byte
    LoopVar         var byte
    PORTA.2=1
    Pause 50
    
    SWITCH:
           Pause 250
           IF PORTA.4 = 1 Then End
           MaskFromPORTB=PORTB & %00001111 ' Get only PORTB<3:0> bits 
           amountofpulsout = maskfromPORTB
           if amountofpulsout>0 then 
                for loopvar=0 to amountofpulsout
                   PulsOut PORTA.2, 50000
                   Pause 500
                next
                end
           endif
           GoTo SWITCH
    about 118 words nows... can use PIC12c508 or else 12c or 12F for that. without any need of external crystal or oscillator.

    if you remove PULSOUT statement and you use those line
    Code:
    PORTA.2=0
    PAUSE 500
    PORTA.2=1
    the whole code will take about 87 words...
    Last edited by mister_e; - 16th January 2005 at 21:02.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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