News:

Let's find out together what makes a PIC Tick!

Main Menu

Need add new feature!

Started by atomix, Jul 01, 2021, 09:48 AM

Previous topic - Next topic

atomix

to fill eeprom from any address

code:

org 0xF00000
db 0,1,3,4,5

org 0xF00100
db 6,7,8,9

compiler print:
ERROR
The program code does not fit in the device. Reduce the program size, or switch to a larger device.
Warning! Program has exceeded 64K bytes of flash memory.
Warning! If problems occur, move any Cdata statements closer to the beginning of the BASIC program"

trastikata

Hello,

it is not very clear what are you trying to achieve. Could you post the program code here including device type. You are talking about EEPROM, but code suggests something different, and the address does not seem to be an EEPROM address.


Yasin

For eprom, you should check EDATA and EWRITE.

atomix

#3
Device 18F46K22

EData must be start by 0

I need write EEPROM data to any position (this is be must in design mode, not by runtime)

For example i want write to 1023 position in EEPROM.

top204:
please add this feature to compiler

Giuseppe

You can already write in eeprom with the ERead command
Syntax
Variable = Eread Address
See page 391 of the manual

Yasin

Quote from: Giuseppe on Jul 01, 2021, 02:25 PMYou can already write in eeprom with the ERead command
Syntax
Variable = Eread Address
See page 391 of the manual

-This runtime instantly reads the eeprom.


-I am using EDATA. I fill the entire eeprom. I write $FF (or 255) where I don't use it. I use symbols for convenience.

For example;
Symbol SMQ = 8
Symbol GRP = 255
Symbol SID = 1
Symbol SUQ = 0
Symbol DVC = "T"
...
...
...
...


EData 049,050,051,052,053,054,055,DVC,GRP,SID,SUQ,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255,255,255,255,_


trastikata

Quote from: atomix on Jul 01, 2021, 02:07 PMDevice 18F46K22
EData must be start by 0
I need write EEPROM data to any position (this is be must in design mode, not by runtime)
For example i want write to 1023 position in EEPROM.

I see what you mean, as Yasin suggested you can fill the EEPROM with FF values, however that would be a lot of writing for higher EEPROM addresses. If you need to put one or two values only there is another workaround like this code, which will write 255 at EEPROM address 1022 and 10 at address 1023. :

Device = 18F46K22
Declare Xtal = 4

Declare EEPROM_Address = 0xF003FE

Main:
   EData 255,10


Third solution I've been using in the past is to call small subroutine at device startup that will write default values to the EEPROM at certain address only once and then will write a marker at another unused EEPROM address indicating that default values have been initialized.

Device = 18F46K22
Declare Xtal = 4

Main:
    GoSub Check_EEPROM
    'Run main program
    End

Check_EEPROM:
    If ERead 255 <> 123 Then    'Check marker at address 255 if default values at address 1023 have been written
        EWrite 1022, [255]      'If not, write default values
        DelayMS 7
        EWrite 1023, [10]       'If not, write default values
        DelayMS 7
        EWrite 255, [123]       'Write marker that default values have been written
        DelayMS 7
    EndIf
Return   

But I agree would be best if we can use Edata in conjunction with an address. 

top204

To fill all of the EEPROM on a device that has 1024 bytes of it, it is a simple EData table:

    EData {$00,$01,$03,$04,$05,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,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$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF}

To fill only up to offset $0104 with the bytes you had in your post:
    EData {$00,$01,$03,$04,$05,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
           $06,$07,$08,$09}

Because the edata tables are of equal length per line, it is simplicity to add more because the above has 32 bytes per table line, so 32 of them would be 1024 etc...

A new directive is not required.

EEPROM data does not use any code (flash) memory, so they do not bulk up a program or slow it down etc...

atomix

And you can then make the ORG command so that it allows you to specify a value greater than the size of the flash memory.

Or the EData command would allow you to specify an address.

It's just very inconvenient to write large eeprom tables and then keep track of the values that need to be changed in them.

Or you can make a directive that would simply add any code to the .asm file

atomix

#9
code:

;---------------------------------------------
__eof
;---------------------------------------------
; EEPROM DATA
org 0XF00000
    db 10,50,100,0
org 0XF003F0
    db 1,2,3,4

trastikata

Quote from: atomix on Jul 02, 2021, 06:29 AMtop204:  PLEASE! PLEASE! PLEASE!

Add the ability to use the org command with a large address. I tried to use mpasmwin.exe with the code and everything worked correctly

I am ready to pay for this revision.
I really need it.


Can't you spare few code lines and use the method I've posted above - to call small subroutine at device startup that will write default values to the EEPROM at certain address only once and then will write a marker at another unused EEPROM address indicating that default values have been initialized?

Main:
    GoSub Check_EEPROM
    'Run main program
    End

Check_EEPROM:
    If ERead 255 <> 123 Then    'Check marker at address 255 if default values at address 1008 have been written
        EWrite 1008, [1]        'If not, write default values
        DelayMS 7
        EWrite 1009, [2]        'If not, write default values
        DelayMS 7
        EWrite 1010, [3]        'If not, write default values
        DelayMS 7
        EWrite 1011, [4]        'If not, write default values
        DelayMS 7
        EWrite 255, [123]       'Write marker that default values have been written
        DelayMS 7
    EndIf
Return   
   
EData 10,50,100,0

atomix

No. I want use only this method.

org 0XF003F0
    db 1,2,3,4

JonW

You can also use a programmer to write to the location without having the data table in the program.  You can then read back the hex file and the EEdata from the programmer and save the hex file.  If you need to manipulate the value in the table for serialisation etc then just write a simple program to manipulate the exact location in the Hex file before writing to the MCU

trastikata

Quote from: atomix on Jul 02, 2021, 08:22 AMNo. I want use only this method.

org 0XF003F0
    db 1,2,3,4

Maybe I am missing something - is there a particular reason for insisting on this method? The program still will be fully functional regardless which of the above posted methods you use!

Dompie

After all the different methods the members of this forum gave and your response
Quote from: atomix on Jul 02, 2021, 08:22 AMNo. I want use only this method.

org 0XF003F0
    db 1,2,3,4
...than I think there will be only one method: Write your own compiler

Johan

atomix

#15
Above, I gave the only correct solution, and by the way it works in mpasmwin.exe

And I just ask the developer to make it so that you can use the Org command with large addresses.

top204

#16
An "assembler" Org directive cannot simply be placed anywhere in the high level code, because it will automatically make the compiler's assembler code also start at that address, and procedures and other code will automatically be placed above the address because procedures are generated above the main BASIC code, but it is the assembler that translates the mnemonics into the binary values that the device uses.

Also, devices have different address' for EEPROM now, so creating EEPROM at a specific address within a code listing is crazy and is asking for problems in time, when the code gets transferred to another device type. That's why the device's PPI file has the EEPROM address for a specific device within it.

Being able to use the Org directive anywhere in native assemble code is very, very, very differnt to being able to use it anywhere in a high level language.

The offsets within the EEPROM data block can be made from the Symbol directive, or the Edata table can be structured to create the name for the offset within the table itself:

EE_Offset_0000 EData {$00,$01,$03,$04,$05,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,
                      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF}
EE_Offset_0100 EData {$06,$07,$08,$09}

There is no need for a new directive, just a bit of thought in the structure of a program's listing.

trastikata

Quote from: atomix on Jul 02, 2021, 09:42 AMIf all of the above tips did not suit me, then it means they are 100% unsuitable for me.

 :) You have multiple ways, including manual hex editing, to put something in the EEPROM and I don't see why you are insisting on this method only - obviously it is not program related, seems something very hush-hush, sorry for not being able to help.

top204

#18
You can go native assembler within the high level language, and do what I used to do 20-odd years ago and save the flash memory address, change it with Org, then restore the address to what it was:

Asm-
PrevFlashAddress Equ $      ' Save this flash memory address
    Org 0x310100            ' Point to the EEPROM area (plus 0x0100) for this device (18F25K20)
    db 06, 07, 08, 09       ' Place some values in the EEPROM area
    Org PrevFlashAddress    ' Restore the previous flash memory address
Endasm-

The above will work with the current assembler program, but the next generation assembler program for the newer devices will not allow it. Viewing the .Lst file shows the flash memory address' are OK:

  00000054            01256 PREVFLASHADDRESS equ $
310100                01257     org 0X310100
310100 0706 0908      01258     db 06, 07, 08, 09
000054                01259     org PREVFLASHADDRESS


The above code block shows how flexible the compiler is, when raw assembler mnemonics can be added to the high level language so easily.

atomix

#19
That's what I need!
On old devices, such as PIС18F46K22, this will continue to work, I do not need new devices.