Jump to content

MIOS persistent memory management (flash/EEPROM)


canrull
 Share

Recommended Posts

Hi there.

First of all, I am grateful for the existence of this project!

I want to program an application that allows storing persistent data.

I understand I have two options: to use internal EEPROM and to use flash memory (I would use it if more than 256 bytes are needed).

1) Which space of the internal EEPROM is free for application usage? I read the memory using MIDI Sysex message (implemented by MIOS) and I saw the starting bytes were used (I asume by MIOS).

2) How can I change content for flash memory from outside the application (initial values)? I understand I can declare a const array, but how do I know the starting address asigned by compiler in order to address it from the MIOS Sysex MIDI message that changes flash content?

Thanks in advance!

Canrull

Link to comment
Share on other sites

Hi canrull,

I understand I have two options: to use internal EEPROM and to use flash memory

Without knowing the exact use of your application, normally it's the best option to use the third option: a bankstick. This way you don't come in conflict with address spaces and it's also possible to send/receive/convert bankstick contents via sysEx.

See MIOS_BANKSTICK_ReadPage() and MIOS_BANKSTICK_WritePage() in the MIOS Function Reference and Bankstick on the uCapps page.

Best regards,

Michael

Link to comment
Share on other sites

Thanks for your reply, Michael.

I am developing the application using C language on a PIC18F452, it will be a kind of MIDI filtering solution based on MIOS, with MIDI IN/OUT as input/output.

I am not planning to use banksticks, as I want to keep it very simple (use basically a CORE module with MIOS).

I want to keep some settings for the application, i.e. filtering options.

And it seems the easiest way to go is using EEPROM (256 bytes) or program flash (const variables in code).

Any other ideas about my two questions?

Regards,

Canrull

Link to comment
Share on other sites

right, if 256 bytes are enough for your purpose:

(although it's just one 2 EUR IC and four wires for one BS, so it's not really making things more complicated and you get a lot more storage space that can be exchanged easily ;) )

The program code is stored in Flash Memory, so it's easier (and safer) to use the available 256 bytes in EEPROM:

It's better (and easier) to store such data into the internal EEPROM or into an external BankStick. The EEPROM provides 256 bytes, the external BankStick up to 8*64k

data EEPROM memory (PIC 18F452: 0xf00000-0xf000ff)

to be found in hex2syx.pl:

# address calculated with following formula:

# AU = (address >> 15) & 0x07

# AH = (address >> 10) & 0x7f

# AL = (address >> 3) & 0x7f

# address = (AH << 10) | (AL << 3)

# if address < 0x08000 : program memory (PIC: 0x0000-0x7fff)

# if address >= 0x08000 and address < 0x080ff : data EEPROM memory (PIC: 0xf00000-0xf000ff)

# if address >= 0x10000 and address < 0x1ffff : BankStick memory (MIOS: 0x400000-0x40ffff)

#

# only supported for PIC18F4620 (64k PIC):

# if address >= 0x08000 and address < 0x083ff : data EEPROM memory (PIC: 0xf00000-0xf003ff)

# if address > 0x28000 and address < 0x28fff : (AU=1) program memory (PIC: 0x8000-0xffff)

maybe you're interested in this posting' date=' too:

it isn't possible to store code in a BankStick, the PIC can only execute from internal Flash.

finally, I guess you already know the relevant MIOS handlers:

Class: MIOS_EEPROM

MIOS_EEPROM_Read

MIOS_EEPROM_ReadPage

MIOS_EEPROM_Write

MIOS_EEPROM_WritePage

Class: MIOS_FLASH

MIOS_FLASH_Read

MIOS_FLASH_Write

Class: MIOS_BANKSTICK

MIOS_BANKSTICK_CtrlGet

MIOS_BANKSTICK_CtrlSet

MIOS_BANKSTICK_Read

MIOS_BANKSTICK_ReadPage

MIOS_BANKSTICK_Write

MIOS_BANKSTICK_WritePage

Hope this helps ;)

Cheers!

Michael

Link to comment
Share on other sites

Thanks, Michael.

I still have one relevant doubt, about the EEPROM memory space (0x8000 to 0x80ff).

Is this space totally usable for my applications or does MIOS use any address range for storing internal data?

I am saying that because I found some significant values when I read this memory using a MIOS SysEx memory read.

Thanks again,

Canrull

Link to comment
Share on other sites

I'm not exactly sure, 'cause I never used the EEPROM so far, but the bootloader is definitely *not* stored in there ... and in SEQ v3, the starting address for the EPROM where 1 patch can be stored (as an alternative to a BS) is the same as the one I wrote above.

Have you had another app stored on the PIC before? Maybe an MB64/e or a Seq? This way some data may have gotten in the EEPROM area.

Anyway, as a programmer, you should have MIOS and your application by hand to update again by SysEx. And if you got a Burner Module, you can re-burn the bootloader any time. I doubt it's possible to damage the chip by writing some data in the EEPROM.

So it should be relatively save to write data in there –

If I were you, I'd try the EEPROM, but don't blame me if something goes wrong ;D

Cheers,

Michael

Link to comment
Share on other sites

Hi, Michael.

This is my first Midibox project, I have built the core and connected the LCD, uploaded the MIOS and tested with a loop that MIDI IN flows to MIDI OUT. That's all... I am designing the application now, using C. So the thing was to know if I could use freely the EEPROM to store parameters...

I am a little concerned about storing data, as you say...

Anyone else had any experience storing data in the internal EEPROM?

Regards

Link to comment
Share on other sites

  • 1 month later...

Hi canrull,

I just tried this, it's actually a lot easier than I expected 'cause you don't have to mess with MIOS-Address ranges  ::)

You just have to call MIOS_EEPROM_Read or Write (or Page-Acess). The adress range is simply from 0x00 to 0xFF (PIC18F452).

// two chars
unsigned char bank = 12;
unsigned char patch = 127;

// save to EEPROM
MIOS_EEPROM_Write(0x00,bank);
MIOS_EEPROM_Write(0x01,patch);

// read from EEPROM
bank = MIOS_EEPROM_Read(0x00);
patch = MIOS_EEPROM_Read(0x01);

Best regards,

Michael

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...