How to store a nr on a 18f46j50

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

How to store a nr on a 18f46j50

Post by Desdewit »

How can I enter a 12 digit nr via keypad and store it on a pic18f46j50 without losing the digits when power is removed :?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to store a nr on a 18f46j50

Post by Benj »

Hello,

On newer devices like this Microchip got rid of the EEPROM peripheral and simply replaced it with the functionality to read and write the ROM flash directly. This means you can assign some or all of your spare ROM to storing data in a none volatile format.

Flowcode currently does not support this feature directly but you should be able to perform this functionality by creating a macro to read a byte from a certain address and a macro to write a byte to an address. The actual reading and writing would have to be performed by C code which you should be able to get hold of.

I think this has been done before on the forums so I would start by searching here and see if you can find anything useful.

Let us know how your getting on.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to store a nr on a 18f46j50

Post by Benj »

This might be useful as it explains how it is done as well as the caveats such as having to erase the flash a page at a time.

http://ww1.microchip.com/downloads/en/a ... 01095c.pdf

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: How to store a nr on a 18f46j50

Post by Desdewit »

Hi Benj

I need to make a program were I can enter and save cell nr's.
Do you know if anyone managed to use flash like normal eeprom with flowcode?
I've searched the forums without success and my poor C programming skills are not helping either :oops: :oops:
Will it be possible to use a c-block and write the code in asm from the data sheet samples? (my asm skills are a bit better the my C-skills)

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: How to store a nr on a 18f46j50

Post by Kenrix2 »

I made some Flowcode V5 flash memory macros to be used on some 12 and 16 series devices. You can't use flash memory like eeprom. First you need make sure the address you want to write to has been previously erased. Then you can write your data. If you need to erase it, you have to erase an entire row. If there is any data you need to keep that is in that row you have to copy it to ram before you erase it and then rewrite it. Also, flash rom's endurance is lower than eeprom so you have to be careful how many times you do this to a certain row. There might be an easy solution if you don't need to do lots of rewrites. If your device programmer erases all the flash memory locations during programming you can just write to sequential locations without having to deal with erase in your code. The link above that Benj posted seems to aleviate some of the issues if you want to use that concept. There is almost always example asm code in the data sheets for you to use as a guide to create your own Flowcode macros in asm if you like. You also have the option to use an external eeprom since V5 Pro has communication component macros built-in. Here is the link if you want to experiment with the flash memory macros but, I have no idea if they will work on 18 series micros since I don't use them.
http://www.matrixmultimedia.com/mmforum ... ory#p57004

Post Reply