• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Setting EEPROM in ASM30


Well-Known Member
Thread starter #1
I'm using MPLAB to program a PIC24F16KA101, and the assembler is ASM30.

I can program data into the program space by setting a location with a .org directive and .pword directives, like this:-
.org   0xA5FC - 0x204
.pword 0xFF6577,0xFF7562,0xFF2e6b,0xFF756d
Is there some equivalent way of putting data into the eeprom?


Active Member
If I remember right, for the 16 bit PICs, you set the origin at 0xF00000 to assign data to the EEPROM

As far as I know that works for PIC24 and DSPIC etc., if the particular device includes EEPROM - not all do.

Edit - there again, looking at the data sheet, it could be 0x7FFE00h
I may be getting mixed up between PIC families..


Well-Known Member
Thread starter #3
I've managed to set the .org command to set program memory as follows:-

.org 0x2BF0 - 0x204
.word 0x6577;

That sets program location 0x2BF0 to be 0x006577

However, when I try
.org 0x7FFEA0 - 0x204
.word 0x6577;

it doesn't compile, with or without the -0x204, and it gives the following error message:-

lin_step_01.o: Link Error: Could not allocate section .text, size = 8388258 PC units, attributes = code Link Error: Could not allocate program memory
It seems to be trying to zero all the locations from 0 to 0x7FFEA0.

When I inlcude
.org 0x2BF0 - 0x204
.word 0x6577;
all the memory locations from the end of my code to 0x2BF0 become zero, and that is what makes me think that setting .org to a higher address will try to make all the locations below it equal to zero, which isn't possible and causes the error.


Well-Known Member
Most Helpful Member
Could you write to EEPROM in code and then download the whole chip. The hex file should contain the address to use to write EEPROM.



Well-Known Member
Thread starter #5
Ok I did that, but either it didn't help or I couldn't see how to use it.
The .hex file contained
The "40204" is what is at the start of memory, and the "ABAB" is what I put at the start of EEPROM

That seems to have an offset of 0xFF but any variation of that still gives the same error.


Well-Known Member
Most Helpful Member
Long time since I've looked at a hex file but if you lookup the format you should be able to work it out.


Nigel Goodwin

Super Moderator
Most Helpful Member
I've not used ASM30, but in the older 14 bit assemblers the assembler instructions told you how to include EEPROM data in the source code, I'd like to think that ASM30 does as well?.

EE World Online Articles