Making Program Code Space your playground...


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    35


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Yes I was using EEPROM for array storage but the 16f877 has only 256 bytes available. I will need about 4k just for pattern storage. That is why I'm looking at using the code program space. The problem seems to be my use of binary data input. Here's the code i'm using for testing.


    ' PCode.bas
    ' Quick Demo Program
    ' showing how you can play with
    ' Program Code Space

    Define debug_pacing 1000 'serial setup
    Define debug_reg porta
    Define debug_bit 0
    Define debug_baud 2400
    Define debug_mode 1
    TRISB= %00000000
    TRISa= %00000 '
    '

    ' RAM Assignments & Variables
    ' ---------------------------
    PCAddress var WORD ' Used to determine ADDRESS of Data
    ' within Program Code space
    PCData var BYTE ' Data Variable - in this example a BYTE
    ' but could be a WORD as each memory
    ' address is capable of storing 14-bits
    PCWord var WORD
    '
    ' Start Program
    ' =============
    Pause 2000
    DoitAgain:
    PCAddress=7190 ' Pointer to start of Data area
    '
    ' Read & Display till we get a stop character
    ' -------------------------------------------
    ReadCodeLoop:
    READCODE PCAddress,PCData ' Sequentially read bytes
    If PCData>0 then ' Until a Stop character is found

    debug "ADD=", dec pcaddress 'lcd display
    debug 254,192
    debug "DAT=", dec pcdata

    PCAddress=PCAddress+1 ' Remembering to increment our address
    portB=pcdata 'output data to portB LEDs

    Pause 300
    Goto ReadCodeLoop
    endif
    Pause 50

    Goto DoitAgain

    End


    Asm
    CODE 7190



    DB 00000001
    DB 00000010
    DB 00000100
    DB 00001000
    DB 00010000
    DB 00100000
    DB 01000000
    DB 10000000
    DB 0

    Endasm




    ........................
    RESULTS

    debug LCD readout values
    00000001 = 1 OK
    00000010 = 10 NG
    00000100 = 100 NG
    00001000 = 232 NG
    00010000 = 16 OK
    00100000 = 160 NG
    01000000 = 64 OK
    10000000 = 128 OK
    Last edited by Homerclese; - 9th October 2005 at 01:23.

  2. #2
    El_AMPo's Avatar
    El_AMPo Guest


    Did you find this post helpful? Yes | No

    Default Using program space for tables on smaller PICs

    The first method shown work only on 16F87X flash memory PICs as far as i know.

    The second method posted that used PEEKCODE and POKECODE works great in smaller pics.

    ...for the ones that didn'd get it in the first example

    --[To Write]--
    Just include after the END tag of the program:

    POKECODE @[start address],[byte0],[byte1],[byte2]....(up to 79)

    (note: start address must be bigger than your program size, and the command only works when programming the pic)

    --[To Read]--

    (use something like...)

    OUT var byte
    y var word

    For y = [start address] to [start address + nºbytes]
    PEEKCODE y, OUT
    Next y


    hope it helps...
    Last edited by El_AMPo; - 17th January 2006 at 06:50.

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Determine free memory space

    How do I determine the free memory space?

    PBP manual: The listing file may be examined to determine program addresses.

    I've appended a test list file (original .LST file, renamed .TXT for uploading) generated by MCS.

    How must I read & understand this file?

    PIC16F690's Memory Map looks like this:
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2728&stc=1&d=121534385 0">
    Attached Images Attached Images  
    Attached Files Attached Files
    Roger

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Roger

    MPLAB, Program window ... does it sound something to You ???

    ... Lol

    With MCS, have a look to the SMALL characters at the bottom left part of your screen ...

    ...

    Alain
    Last edited by Acetronics2; - 6th July 2008 at 13:02.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Bonjour Alain,

    Sorry, I'm still an amateur and I don't use MPLAB...

    Are you meaning I just have to add the amount of words in MCS to the memory starting adress?

    It can't be that simple?!
    Roger

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Roger

    Not so simple ...

    say it is a 16F628 with 2k memory ( 2048 words )

    2048 minus the "little number" is the first memory adress you can use for placing tables ... ( remember the default DEC radix for PbP !!! )

    to be sure ... you can let some "blank lines" ... before the Table. Or begin your table on a "round" adress ... 2FF, or 1200 i.e. ( Remember A good programmer NEVER adds mods to his programs !!! ... LoL ...)


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default K.I.S.S Method ...

    Bonsoir Roger,

    Have a look to those nice Subroutines ...

    as you see they are placed at the end of the Basic File ...

    Code:
    END ' This is the Program END
    
    
    '*****************************************************************************
    '*****************************************************************************
    'Tables de linéarisation
    '*****************************************************************************
    '*****************************************************************************
    
    
    '*****************************************************************************
    Linearisation2:'Linearisation complète Courbe A(15A)> Linéaire B(1B)
    '*****************************************************************************
    
    LOOKUP Lecture, [  0,  0,  0,  0,  0,  0,  4, 16, 16, 16,   18, 21, 25, 25, 26, 26, 26, 27, 27, 27,   28, 28, 28, 29, 29, 30, 30, 30, 31, 31,   31, 32, 32, 32, 33, 33, 33, 34, 34, 34,   35, 35, 35, 36, 36, 37, 37, 37, 38, 38,_
    				  38, 39, 39, 39, 40, 40, 40, 41, 41, 41,   42, 42, 42, 43, 43, 43, 44, 44, 45, 45,   45, 46, 46, 46, 47, 47, 47, 48, 48, 48,   49, 49, 49, 50, 50, 50, 51, 51, 52, 52,   52, 53, 53, 53, 54, 54, 54, 55, 55, 55,_
    				  56, 56, 56, 57, 57, 57, 58, 58, 59, 59,   59, 60, 60, 60, 61, 61, 61, 62, 62, 62,   63, 63, 63, 64, 64, 64, 65, 65, 65, 66,   66, 67, 67, 67, 68, 68, 68, 69, 69, 69,   70, 70, 70, 71, 71, 71, 72, 72, 72, 73,_
    				  73, 74, 74, 74, 75, 75, 75, 76, 76, 76,   77, 77, 78, 78, 79, 80, 80, 81, 82, 83,   83, 84, 85, 85, 86, 87, 87, 88, 89, 89,   90, 91, 92, 92, 93, 94, 94, 95, 96, 96,   97, 98, 99, 99,100,101,101,102,104,106,_
    				 108,110,112,114,116,118,120,122,124,126,  128,130,132,134,136,138,140,142,144,146,  148,150,152,155,157,159,161,163,165,167,  169,171,173,175,177,179,181,183,185,187,  189,191,193,195,197,199,201,205,208,214,_
    				 220,230,240,250,255,255], Result
    				 
    RETURN
    
    END
    
    '*****************************************************************************
    Linearisation1:'Linéarisation exp simple à 26 points
    '*****************************************************************************
    
    LOOKUP Lecture, [  1,  1,  1,  1,  1,  2,  2,  2,  2,  3,    3,  3,  3,  4,  4,  4,  5,  5,  5,  6,    6,  7,  8,  9, 10, 11, 12, 12], Result
    				  								  
    RETURN
    
    END
    
    '*****************************************************************************
    '****************************************************
    PbP will AUTOMATICALLY place them in the free memory space ... with some blanks lines before !!!

    just use a "Gosub Linearisation2 " in your program and PbP will do all the Work !!!

    Yes ..., you can cry ...

    Alain
    Last edited by Acetronics2; - 6th July 2008 at 16:48.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  3. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  4. Need more code space
    By ghutchison in forum General
    Replies: 1
    Last Post: - 12th February 2005, 20:54
  5. oscillator code and placement within program
    By bartman in forum mel PIC BASIC
    Replies: 14
    Last Post: - 14th December 2004, 02:39

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