'reserving' memory space


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1

    Default 'reserving' memory space

    I want to 'reserve' a fixed chunk of program memory so that I can load code from a serial eeprom... proberbly a similar thing to a boot loader...

    I was thinking of using the assembler ORG command but i was wondering if their was a spacific way of doing it in picbasic?

    What aproches do people use?

    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I find this quite useful - especially in PICs which have insufficient EEPROM for my needs...

    Code:
    	'
    	'	Executable Program Starts Here
    	'	==============================
    	goto JumpStart
    
    	'
    	'	System References
    	'	================
    
    		'
    		'	SETUPs
    		'	------
    Setups:
    	ASM
    
    	db	0xA4,0xA5,0xB0,0xB1,0xB2,0xB3,0xB4,0xD0	;  00-07
    	db	0xD1,0xD2,0xD5,0xD6,0xD9,0xDA,0xDD,0xDE ;  08-15
    	db	0xE1,0xE2,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA ;  16-23
    	db	0xEB,0xEC,0xED,0xEE,0xF0,0xF1,0xF2,0xF4 ;  24-31
    	db	0xFA,0xF9,0xEF,0x00,0x00,0x00,0x00,0x00 ;  32-39
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  40-47
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  48-55
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  56-63
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  64-71
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  72-79
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  80-87
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ;  88-95
    	db	0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0x00,0x00 ;  96-103
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 104-111
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 112-119
    	db	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 120-127
    
    	ENDASM
    
    JumpStart:
    Now, you can reserve as little or as much Programspace as you want and PICBasic takes care of everything else. The most I'd ever done was 8kB, but it sure is handy (and saves on having an external EEPROM). Just remember how much you've allocated and never to do write operations outside of your allocated space (otherwise you'll corrupt your own program).

    This is a great way for long-term but occasional Data-Logging (like the Plastic Chickens you have in your industrial Fridge or Freezers) as you really minimalise your parts count.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    hmmm, interesting...
    I'm assuming i can then use ORG to position it in memory?

    Thanks mel

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Actually I don't do that, because I prefer PBP to position it's internals for itself. If you start using ORG then you could, potentially, run the risk of having PBP create code that could intrude into your reserved space. All I do is workout the address of the start Label (in my previous example 'Setups:') and reference everything from that starting point. The added advantage is that all the reports for BYTE or WORD usage for your PIC take into account your Reserved Space and you get a better feel for how you're filling your PIC up. If you decide you are going to use ORG and position your reserved space up in high memory (nothing stopping you doing that), then you don't get a clear idea of how big your PBP code is, and how much you've got vacant before you intrude into your reserved space.

    And before you turn around and ask "How can I work out how to get the address of a Label?", let me refer you to a three-year-old thread...

    http://www.picbasic.co.uk/forum/showthread.php?t=3881

  6. #6


    Did you find this post helpful? Yes | No

    Default

    ok, going to have to come clean...

    the reason i want to block off some memory addresses is because one of my original PIC's (877A) has faulty memory locations due to a slight power surge and brownout while being programed... yes, my PC PSU was wrecked... luckerly the only other damage was my graphics card...

    i have a low level, really basic task for it to do, if i can get the program to skip the affected memory locations...

    The blocks are...

    0x0008 to 0x003F
    0x0108 to 0x013F
    0x0208 to 0x023F
    0x0308 to 0x033F
    0x0408 to 0x043F
    0x0508 to 0x053F
    0x0608 to 0x063F
    0x0708 to 0x073F

    Anyone see a paturn?... lol

    the thaught occured to me to alter the ASM so that the memory table thing....
    Code:
    RAM_START       		EQU	00020h
    RAM_END         		EQU	001EFh
    RAM_BANKS       		EQU	00004h
    BANK0_START     		EQU	00020h
    BANK0_END       		EQU	0007Fh
    BANK1_START     		EQU	000A0h
    BANK1_END       		EQU	000EFh
    BANK2_START     		EQU	00110h
    BANK2_END       		EQU	0016Fh
    BANK3_START     		EQU	00190h
    BANK3_END       		EQU	001EFh
    EEPROM_START    		EQU	02100h
    EEPROM_END      		EQU	021FFh
    avoides the faulty locations and recompile it using mplabs compiler...

    But then i realised it wasn't going to be that easy...

    :edit
    Having said that... i could alter EEPROM_START to after the first bad block, manually insert a jump followed by enough 3FFF's, and hope the program fits in befor the seconds one (unlikely)...
    Last edited by comwarrior; - 23rd September 2009 at 22:13.

Similar Threads

  1. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  2. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  3. Replies: 4
    Last Post: - 2nd March 2007, 06:12
  4. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38
  5. Memory Space of the PIC16F84...
    By Tear in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 19:55

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