• Pic® Basic


  • Writing compact code

    by Tim Box

    There will nearly always come a time when the code space in your PIC® runs short and you start to think about making some savings. Unfortunately this is not the best time to start thinking about it.

    You really need to think small from the start. So how is this done? Like most things to get good at it you need practice, but here is a simple example to start you in the right direction

    Variables

    Every time you use a variable either in a decision-making or a maths statement the code taken is proportional to the variable used.

    Take these examples

    IF VARA = VARB THEN GOTO CODE_A

    VARA = VARB * VARC

    With the Vars as BYTE’s 6 words and 36 words
    With the Vars as WORD’s 10 words and 40 words
    With the Vars as DWORD’s 18 words and 65 words

    As you can see it pays to keep the numbers small.
  • Recent Activity

    xldaedalus-432

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    xldaedalus Today, 18:21 Go to last post
    Les-15

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    Les Today, 13:05 Go to last post
    amod-29593

    Multiple functions by a single switch

    Thread Starter: amod

    Hi, How can I use multiple function by a single switch.I want to use 4 functions by a single switch.

    amod Today, 15:31 Go to last post
    Oldhack-15978

    FUSES for PIC18F47K20

    Thread Starter: gtv_pic

    000 Good morning I am using the PIC18F47K20 and in the help of the proton I did not locate the FUSES for said micro. Where can I locate...

    Oldhack Today, 16:34 Go to last post