Go Down

Topic: Atmel 93c series serial eeprom library (Read 3109 times) previous topic - next topic

bungalally

G'day everyone.

I have been just getting into arduino and programming in general but that hasn't stopped me from trying to write a library.

Amongst some components i pulled out of motherboards and sounds cards was an Atmel at93c66 Serial eeprom chip.

Working from the datasheet and tutorials i have written this library to work with the three different chips 46, 56, 66 and the two organisations 8 or 16 bit.

I have included the code as a zip.

I would really like some feedback on my code, if i'm lucky someone to test it on the other 2 chips.

If i was to distribute this code what would be the best way to do this? ( licence, location etc)

jgoulder

Sounds like you are in the same boat as me.

I have looked over your code and I think it's a great start.  I have a few comments:

1. There are a lot of magic numbers (i.e. B101).  Give them a name so they make your code more readable.
2. _shiftIn and _shiftOut have access to the private variables there is no need to pass them in as parameters
3. You are always shifting MSBFIRST.  Why is that a parameter?
4. You have a mixture of byte/word and uint types, why not just stick with all one or the other?
5. I am not sure how long digitalWrite's take but you want to make sure you don't exceed the max Fsk frequency.
6. Since this is a C++ class why not make the AT93 Class an abstract base class and have the different versions of the part be subclasses?
7. You have lots of header comments but very few comments in the code itself.  Comments are your friend!


I don't have any of these chips but I would test them out if I had one.

As far as distribution, you can put it in the Playground section (http://arduino.cc/playground/) or upload it to GitHub (http://www.github.com).

The choice of license is up to you but I would recommend the LGPL (http://www.gnu.org/licenses/lgpl.html)

Hope that helps.

bungalally

thanks jgoulder for your reply

thanks for the good feedback,
ok so
1. these magic numbers are a start bit and then an opcode, some of the opcodes extend into the address frame (writeall) of the instruction so that is why some are longer than others. numbers that come after this are written to cycle the clock for the correct number of cycles.

2. I don't get really what you mean by this. I have used a private function as the standard shiftin/ shiftout function in the Arduino does 8 clock cycles at a time for a byte. So instead these private functions can be set to any length.

3. The shiftin/shiftout functions can be set to either most significant bit first or least significant bit first. I have used this as the function will then read any variable from basically left to right.

4. For certain functions ie reading and writing bytes from the chip only a byte variable is needed for the data. Depending on the organisation and size of the chip the address is either 8 or 9 bits long, so that is why a word variable is used instead, this in theory i think will also save on ram by using the smallest usable variable needed. the uint types are left over from code i used out of another library which i forget, i think for a pic based program, but is the shift out and shift in functions with a variable length. Which if i could have been bothered and came up with the idea been taken from the arduino code library.

5. i tested it on the chip i got and it seemed to work, so it must not be a problem and also the digital writes come at the start and end of the functions, so i think it won't effect any max frequency.

6. I did think of that but the tutorials i read didn't explain what i needed to do well enough for me to understand. Especially how to set it up to pass any initiating variables.

7. I get what you mean, especially explaining stuff like the magic numbers. 

I don't think many people would be using these chips as it was out of a very old sound card and there are other more commonly used chips preferred by the microcontroller community, i think something along the lines or 27 something.

Ah i didn't relies you could edit the playground section to include your own stuff.

I was thinking something like that.

Thanks for your help. I might get round to posting an updates version sometime soon.

ps. if you're really interested i have included the data sheet

ginger-hippo

hi i have 2 of these 93c56p chips i would really really like to use and i have downloaded the lib but am to thick to figure it out :( please please can you do a demo showing how to use it in a sketch to read write and erase these chips



many many many thanks

Chris

sorcerxl

Hi, I'm also trying to use yout library but won't work. Can you give us some pointers?

Go Up