EEPROM
Moderator: Benj
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM
Hi electron67
You can store numbers form 0 to 32767 by using two EEPROM locations, which will be high bytes(0 to 255) and low bytes (0 to 255).
you can also retrieve the high and low bytes and convert back in to integer (0 to 32767)
For formulas see:
http://www.matrixmultimedia.com/mmforum ... igh#p20779
To do that see:
http://www.matrixmultimedia.com/support ... =602#p1235
Martin
Edit: If you get stuck, I can post a sample Flowchart for you.
You can store numbers form 0 to 32767 by using two EEPROM locations, which will be high bytes(0 to 255) and low bytes (0 to 255).
you can also retrieve the high and low bytes and convert back in to integer (0 to 32767)
For formulas see:
http://www.matrixmultimedia.com/mmforum ... igh#p20779
For your version of Flowcode, you should be asking questions in the correct Flowcode 4 topic area.electron67 wrote:I use Flowcode4.
To do that see:
http://www.matrixmultimedia.com/support ... =602#p1235
Martin
Edit: If you get stuck, I can post a sample Flowchart for you.
Martin
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM
Here is sample flowchart.
Hope it helps
Martin
Hope it helps
Martin
- Attachments
-
- Int to EEPROM.fcf
- (6 KiB) Downloaded 344 times
Martin
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
Re: EEPROM
Hello Martin
Thanks, but not is very clear; in my case, I have a display lcd, need have 2 counting in the same display......... I send you the flowchart. (speak spanish?)
Thanks, but not is very clear; in my case, I have a display lcd, need have 2 counting in the same display......... I send you the flowchart. (speak spanish?)
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM
Sorry only speak english.......justelectron67 wrote:Hello Martin
I send you the flowchart. (speak spanish?)
Martin
-
Spanish_dude
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM
Here is your flowchart altered to store and retrieve numbers from 0 - 9999 as you required.
Note when you first run Flowchart EEPROM will have random numbers stored within it.
If the High bytes (locations 1 and 3) are to high, then you will get a negative number.
So you must change it's contents.
What I do in my software, is when I write to EEPROM, I write 2 different default numbers to 2 locations.
E.G 22 to loc 10 and 65 to loc 11.
Then If I need to read EEPROM ,if value of loc 10 = 22 AND value of loc 11 = 65 THEN I read EEPROM knowing its been previously wrote to.
If the two values at loc 10 and 11 are wrong, I know EEPROM has not been wrote to therefore will not read from it.
I use two locations since chance of both locations have two random numbers that match the correct numbers is very low indeed.
Martin
Note when you first run Flowchart EEPROM will have random numbers stored within it.
If the High bytes (locations 1 and 3) are to high, then you will get a negative number.
So you must change it's contents.
What I do in my software, is when I write to EEPROM, I write 2 different default numbers to 2 locations.
E.G 22 to loc 10 and 65 to loc 11.
Then If I need to read EEPROM ,if value of loc 10 = 22 AND value of loc 11 = 65 THEN I read EEPROM knowing its been previously wrote to.
If the two values at loc 10 and 11 are wrong, I know EEPROM has not been wrote to therefore will not read from it.
I use two locations since chance of both locations have two random numbers that match the correct numbers is very low indeed.
Martin
- Attachments
-
- ContadorLCDv10.fcf
- (14.01 KiB) Downloaded 344 times
Martin
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
Re: EEPROM
Te agradezco la ayuda; estoy tratando de llevar 2 cuentas en un display LCD; pero por lo que veo las variables las tomo como byte, las cambie a INT y perfectamente realizo la cuenta hasta 9999; pero pense en grabar la cuenta que lleva cada contador utilizando la memoria EEPROM pero solo llega el conteo hasta 255; hize los cambio que me señalo Martin pero no logro grabar mas de 255. Te envio el diagrama de flujo, a ver si detectas donde me estoy equivocando.
- Attachments
-
- ContadorLCDv11.fcf
- (17 KiB) Downloaded 297 times
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
Re: EEPROM
Martin
Thank you, I understand in I was wrong.
Spanish_dude
Te agradezco la ayuda con la ultima respuesta de Martin comprendi donde me equivocaba. Es de gran ayuda que alguien entienda el español en el foro; en algunas ocaciones no se puede expresar como uno quisiera en ingles.
Thank you, I understand in I was wrong.
Spanish_dude
Te agradezco la ayuda con la ultima respuesta de Martin comprendi donde me equivocaba. Es de gran ayuda que alguien entienda el español en el foro; en algunas ocaciones no se puede expresar como uno quisiera en ingles.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: EEPROM
Hi electron67,
What I have posted (ContadorLCDv10.fcf) does what you want it to do.
You have to use two EEPROM locations to store numbers above 255, since 255 is the maximum value of each location.
so to store two interger numbers you must use 4 locations.
for a int number e.g 3456 put 128 in the low bytes (loc 0 and 2 of EEPROM) and 13 in the high bytes (loc 1 and 3 of EEPROM)
Then 3456 will be stored in EEPROM for both variables
Press buttons to increase numbers.
Then you can stop flowchart and restart it.
You will then find numbers 3456 will be read from EEPROM and displayed on your LCD.
The flowchart you posted will not work since you are only using 1 EEPROM to sore a number, so the maximum number you can store is 255 as stated above.
Martin
Edit: electron67,
We most have posted at the same time. but will leave this post for reference.
What I have posted (ContadorLCDv10.fcf) does what you want it to do.
You have to use two EEPROM locations to store numbers above 255, since 255 is the maximum value of each location.
so to store two interger numbers you must use 4 locations.
for a int number e.g 3456 put 128 in the low bytes (loc 0 and 2 of EEPROM) and 13 in the high bytes (loc 1 and 3 of EEPROM)
Then 3456 will be stored in EEPROM for both variables
Press buttons to increase numbers.
Then you can stop flowchart and restart it.
You will then find numbers 3456 will be read from EEPROM and displayed on your LCD.
The flowchart you posted will not work since you are only using 1 EEPROM to sore a number, so the maximum number you can store is 255 as stated above.
Martin
Edit: electron67,
We most have posted at the same time. but will leave this post for reference.
Martin
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
Re: EEPROM
Hi Martin
One question more; if I want reset the EEPROM to 0, when the counter is 9999; But not programming another the PIC ?
One question more; if I want reset the EEPROM to 0, when the counter is 9999; But not programming another the PIC ?
-
Spanish_dude
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: EEPROM
You'll need to check the value of your variable and do something like this:
----
Tendrá que comprobar el valor de la variable y hacer algo como esto:
Best regards / Saludos,
Nicolas L. F.
Code: Select all
if (variable >= 9999)
{
// write 0 to EEPROM on address 0, 1, 2 and 3
variable = 0; // reset variable
}Tendrá que comprobar el valor de la variable y hacer algo como esto:
Code: Select all
if (variable >= 9999)
{
// escribir 0 en la memoria EEPROM al sitio 0, 1, 2 y 3
variable = 0;
}Nicolas L. F.
-
electron67
- Posts: 323
- Joined: Sat Jan 12, 2008 2:08 am
- Has thanked: 106 times
- Been thanked: 48 times
Re: EEPROM
Spanish_dude
No conozco el lenguaje C, pero trate de intercalar el procedimiento que me diste en el archivo .c, me marco 128 errores y no lo pude convertir a .hex. En que forma puedo intercalar el procedimiento en flowcode por medio de diagrama de flujo ?
I want reset the EEPROM to 0, when the counter is 9999; But not programming another time the PIC ? utilize flowchart.
No conozco el lenguaje C, pero trate de intercalar el procedimiento que me diste en el archivo .c, me marco 128 errores y no lo pude convertir a .hex. En que forma puedo intercalar el procedimiento en flowcode por medio de diagrama de flujo ?
I want reset the EEPROM to 0, when the counter is 9999; But not programming another time the PIC ? utilize flowchart.