![]() |
EEPROM Code
I've just posted software that can be used to read and write the Electrically Erasable Programmable Read-Only Memory (EEPROM) found in IFI's robot controllers. The code can be found here: http://kevin.org/frc. As always, if you find a bug in the code or a problem with the documentation, please let me know.
-Kevin Here's the readme file: Code:
The source code in eeprom.c/.h contains software to read from |
Re: EEPROM Code
THANK YOU!!!!!!!!!
(Bows and kisses Kevin's feet) The possibilities are so good. P.S. Do you know if this will work on the VEXtroller? P.P.S: Did I say thak you? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (Rather than Double Post) How does data need to be formatted when you pass it to the EEPROM_Write() function? Can you send variables by name? Could you call this function using your printf/serial driver. For instance, type "Field Side: Left," and then have this set a variable (such as "rss" - robot start side") equal to 1 (for instance). And then have the handler write to the EEPROM so that when the robot is turned on again, it knows what side it is on without a switch. Also, I am assuming that the read time is negligable compared to the write time (I.E. one does not need to woory about avoiding interrupts when reading?) |
Re: EEPROM Code
Sweet.
We were considering using the EEPROM when we ran out of code space last year, and this ought to make it a lot easier to do. Thanks! |
Re: EEPROM Code
Quote:
Quote:
Quote:
Quote:
-Kevin |
Re: EEPROM Code
Quote:
Code:
#include <math.h>-Kevin |
Re: EEPROM Code
Very cool, thanks.
|
Re: EEPROM Code
Hi Kevin,
Thanks for all the effort, it looks great and we'll definately be using it. I'd like to make one suggestion though. With so many novice progammers using your code, it's likely that someone will use the EEPROM_Write() function too much, even when the data doesn't need to be updated. A small change to EEPROM_Write() might avoid problems for these folks. Code:
unsigned char EEPROM_Write(unsigned int address, unsigned char data)Thanks again for all the hard work. |
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
So, to write "127" to the first data block would be
Quote:
Quote:
|
Re: EEPROM Code
Yes, that will work.
-Kevin |
Re: EEPROM Code
hrmm. I love the simplicity of this. Last year, i wrote overly complex EEPROM routines to allow data of arbitrary length to be stored with dynamic allocation and FAT table. It turns out, not a whole lot of that functionality was ever needed. A scheme like yours would have workded just fine. It makes me want to smack myself in the face and say "duh".
|
Re: EEPROM Code
How much variable is space is available in the onboard EEPROM?
|
Re: EEPROM Code
Quote:
|
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
It will write only when there is no free space in the write que?
|
Re: EEPROM Code
It risks getting caught in an infinite loop waiting for the queue and breaks the comm sync on the controller?
|
Re: EEPROM Code
Quote:
Code:
// wait, if necessary, for a free slot on the circular queue |
Re: EEPROM Code
Quote:
|
Re: EEPROM Code
Kevin,
I haven't tried this, but from the PIC documentation, it looks like you only have to disable the interrupts during the period that you call "pre-write sequence" and "execute the write" in the EEPROM_Write_Handler routine. You should be able to re-enable the interrupts after these 3 lines (from the 39609b Microchip document, section 7.4) rather than waiting until the 2ms write is complete. This may also eliminate the code error by allowing the high priority interrupts to mostly go on schedule. Mike |
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
Quote:
Quote:
-Kevin |
Re: EEPROM Code
On a slightly different topic, does the addressing go from 0 to 1023 or 1 to 1024?
i.e. can I write to 0? |
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
Thanks, this makes it perfect for recording tables
If you want (say) a table with the five attributes in each row 0, 5, 10, . . . = attribute a 1, 6, 11, . . . = attribute b 2, 7, 12, . . . = attribute c 3, 8, 13, . . . = attribute d 4, 9, 14, . . . = attribute e Then to find a specific row number, you would take the row number, multiply by 5 and subtract five, and then start reading values? |
Re: EEPROM Code
Quote:
|
Re: EEPROM Code
I have met one or two systems which did not, and not having a controller with me at the moment to test it out, I figured I might as well ask.
|
Re: EEPROM Code
I just wrote and tested some quick-n-dirty trig table code. Grab a copy of the EEPROM code here and add the code below. I only create a table covering zero to ninety degrees because sin(x) in the other three quadrants can be derived using sin(x) data in quadrant one (exercise left to the student). I'll release a more polished version at a later time.
This code creates the table: Code:
Code:
Code:
if(Sine_Table(0) == 1) |
Re: EEPROM Code
Quote:
I've got a question about EEPROM_Write(). Code:
unsigned char EEPROM_Write(unsigned int address, unsigned char data) |
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
Quote:
-Kevin |
Re: EEPROM Code
In the eeprom.c released on the 10th of January, I see the following opening lines of code:
//#include "ifi_picdefs.h" #include <p18f8722.h> #include "eeprom.h" Is it safe to uncomment the first line, and remove the specific request for the p18f8722.h info header file, or is that required for the functionality of the code? Basically, as it is now, I won't be able to use it on the '05 controller (unless I modify line 2 every time I want to make the switch, which I could forget eventually). Just checking to see if that's a life or death thing.. I could just test the code, but I am not yet near a FIRST controller. :) |
Re: EEPROM Code
Quote:
-Kevin |
| All times are GMT -5. The time now is 00:13. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi