Jump to content

Accessing the PIC's eeprom


superdavies
 Share

Recommended Posts

Hi

These are the PIC18f452 specs:

Program Memory Type Standard Flash

Program Memory Size (Kbytes) 32

RAM (bytes) 1536

Data EEPROM (bytes) 256

I/O 34

I know the MIOS+Bootstrap+Apps are on the Flash program memory, but what about the RAM and the EEPROM?

Are they useful for something?

This is my question: is it possible to access the EEPROM of the pic for writing something on it ?(I'm thinking about banks and things like these)

How to do?

Thank you for your help!!!

Andrea

Link to comment
Share on other sites

First: You need the Bootstrap Loader on your pic.

Second:Upload the Mios (MIDIbox Operating System)

Third: Now you have to write/modify an programm (aplication) in c or Assembler including the MIOS functions and build a .hex file out of it.

http://www.ucapps.de/howto_tools_mpasm.html

Fourth: Upload the programm.

Fifth: Test it with your midibox.

I´m no programmer, but if you need help by doing it you can ask in the c or assembler forum here.

Best regarts

Markus

Link to comment
Share on other sites

Ok

I know that the writing of th eeprom is included in the mios features, but I would like to know if there's the possibility of writing on eeprom using software like mios studio or other software "out of pic", software running on PC and capable of doing the upload via midi (like the uploading of mios or other apps) this is for avoid of using a standard pic flashing utility like PIC burner.

Is it possible? If so, what is the software and how?

Thank you!!!

Andrea

Link to comment
Share on other sites

Not out of PIC!

You can use an application running on the core to write the eeprom (f.e. MIDOBOX64) or you can use an external software that can write the pic's eeprom from outside ( PC running a software able to do so via midi - midi cable - core stuffed with pic ). As for upload an application without remove the pic from the core using the bootstrap loader, I'm searching for the possibility to do same thing with the writing of the eeprom. possible?

Thanks

Andrea

Link to comment
Share on other sites

I don´t know if I understand you the right way, but with Midi OX you can upload sysex files via midi to the eeprom of your pic.

With this possibility you can upload new applications or only a new bank for your controllers.

Is it that what you need?

Greetz

Link to comment
Share on other sites

Hi

Maybe now I can understand!

I want to write banks data on the pic's eeprom, so I have to write an application (.hex)  with the data I want to store and then I have to upload it with mios studio or with other software that support .syx; I must specify the address of the eeprom to make sure every byte go to the right place (eeprom).

It is right?

Thank you

Link to comment
Share on other sites

Ok

Only one thing: I want be able to write bank datas on the eeprom using my MBHP PIC burner.

Is it possible with the p18 software? the program is in German and I really can't understand nothing! Is it possible to use other software for write the eeprom of the pic18f (instead of P18) but using the same hardware (MBHP)?

Thank you very much!

Andrea

Link to comment
Share on other sites

still have confusion about it

1) I need to write the eeprom

2) I don't want to do this with MIOS because i'm not a programmer, so it wouldn't be easy for me

3) Maybe it's better to write the eeprom from outside the MIOS

4) I think I have two ways: first using software like midiox ecc and upload the data to the eeprom via midi, second using a programmer like MBHP PIC burner or others.

Are these things right?

if so, that's my problems: In the eeprom I really don't have to put application or programs files, but only "numbers" banks values and things like these. So with software like midiox or mios studio how can I do this if I only can upload .hex or .syx? Is there the possibility to convert numbers or simply data file to .hex or .syx and upload them? How can I decide to put them to eeprom and not to flash? And how about a picburner? I'm using MBHP PIC burner and p18 but seems to me that I can't write datas to eeprom and I have the same problem like before, the fact that I can only upload .hex files. Is there other software that can do this using MBHP PIC burner? Do you know if there's instruction for p18 in english?

I know...lot of questions, but I really can't understand the right way...please help me! :)

Bye

Andrea

Link to comment
Share on other sites

Andrea, could you please write more about the reason, why you want to write something into EEPROM?

There are multiple ways for doing this, but to suggest the best way, it's important to know why...

Are you planning to program a new MIDIbox application, or did you find this site via google without background knowledge about the purpose of this forum, and assumed that this is a technical board for common microcontroller programming issues?

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi Thorsten,

No, I don't find the forum via google, I'm only a newbie midiboxer with some question! ???

Maybe it's better for me to explain all the stuffs and all my midibox "story"

I build up my hardware MBHP some months ago for trying to control some "software synths" like from native instruments or other and I used some "pre-built" apps like mb64 or midio and I find them very interesting; I started build another one 1 months ago with the proposal to start to understand more and think about midibox in a new way expecially about the understanding of the language, not really for writing a new one (it's really much for me) but to understand C and the world of Midibox including the microcontroller world and so on. I find very soon that this is really difficult, so I ask a friend of mine ( person that know C language ) to help me with some things and here we are! Maybe for me it will be more confortable to use apps like mb64 v2.4 and use an external eeprom for store the data but In this way iwon't understand nothing...I need to try myself!

THIS IS THE REASON OF MY QUESTION: starting from ain64_din128_dout128_v2_0.zip we made some custom modification to that app for match our project that will include some kind of "presets" for the pots, I mean 20 "user value" that we can call by pressing 10 din, every din will call 10 pots value (and the pots connected to the ain will be "by-passed") , so you have a total of 200 fixed value; I think we call call this a kind of "banks".

My friend told me that there's not enough space in the PIC for specify 200 values one by one and he suggested the possibility of store these values in the eeprom, one value for every byte, ( and so i'm asking if this is possible and how...)  Also if this friend of mine know C language, there's something that he can't do and he's not very expert in PIC programming.

Excuse me for the strange question and the disturb, hope you can understand what I mean, because I really want to know much about the world of programming and the world of microchip, but it's hard and I'm doing it step by step.

Thank you very much for your reply.

Andrea

Link to comment
Share on other sites

Thank you! This finally gives me the right hint to help you - it saved a lot of time that you mentioned all the details.

In order to preload the EEPROM, just create a file called "presets.asm" (or similar)

Add this file to the MAKEFILE.SPEC file (search for MK_SET_OBJ, and add presets.asm like shown here:

MK_SET_OBJ pic18f452.c main.c presets.asm

within the presets.asm file, write:


        list    p=18f452
        radix  dec

        org    0xf00000        ; eeprom base address

        db      0x01, 0x02, 0x03, 0x04

        END
[/code]

as you can see: the EEPROM address space starts at 0xf00000

The EEPROM size of PIC18F452 is 256 bytes (-> 0x00..0xff), you are preloading this range with db entries.

Multiple entries are allowed for better readability

IMPORTANT: the ain64_din128_dout128_v2_0.zip package contains an older version of the makefile generator, which doesn't allow to add assembly files.

SOLUTION: copy the tools and mios_wrapper directory of the most recent wrapper release (sdcc_skeleton_v1_9a) into your working directory - overwrite all existing files.

Thereafter you need to create a new makefile.

Under DOS just type "make", this will execute the "make.bat" script -- a new .hex file will be generated, which contains your application + the EEPROM presets

Under Linux and MacOS, type "perl tools\mkmk.pl MAKEFILE.SPEC", and thereafter "make" ("make" will start GNU-Make)

Best Regards, Thorsten.

Link to comment
Share on other sites

Thank you Thorsten!

This sound really good for me and I understand 100% of what you tell me.

So this evening, when I'll come home I'll try to do what you suggest me and after I can tell you and all community the result of my work.

This is really what I needed, good explanation, in a clear way, very direct, You're the best! Also for people like me, not really good in program languages, this sound to me like a really good thing!

Thank you very much!!!

Andrea

Link to comment
Share on other sites

  • 2 weeks later...

Ok

all works well, we only had some problems with the organizations of the values because we ordered them as matrix of 9x8, in the preset.asm, and after the recompiling, the running app reading from the eeprom always add a 0 value  on every lines of the matrix and the values was not right: we solved the problem changing the matrix from a base 9 to a base 8 thinking about multiple of 2 is better: now the app read the value from the eeprom in the right way!

Thank you for the help, very useful, if someone of you would like to have a copy of the code with the implemention for ther eeprom reading, just ask!

Bye

Andrea

Link to comment
Share on other sites

Andrea it would be great if you could post the code here or in the wiki :)

The thing about the "adding a 0" when you had 9 variables, was also brought up in another thread talking about storing information on the bankstick... It turns out that when using the 'db' directive, the data is stored in a 16bit word with two 8bit values packed together.

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...