Having trouble writing to EEPROM

Okay, so I'm brand new to EEPROM and I have a small program that's meant to read the data off one chip, and then turn around and write it to the next chip that I connect. I've written some check routines into the program, and it seems that only some of the bytes I'm entering are writing properly. I'm very unfamiliar with EEPROM interfaces and the onewire library, so it's possible I'm just doing something totally wrong. Any help getting an accurate copy of this chip would be appreciated. I've included my code and its output below, and I'm using a pair of DS2433 chips wired to pin 10 and ground, with a pullup resistor to the +5V from my arduino on the input pin.

Device present
Data is: 
127 165 211 203 231 31 187 198 128 18 205 137 228 187 177 94 55 108 148 7 68 37 128 164 167 78 246 138 15 176 177 36 171 48 111 178 175 96 31 111 72 179 70 55 155 172 223 81 72 179 70 55 155 172 223 81 56 243 119 54 43 249 197 209 25 97 0 0 0 0 252 169 85 170 85 37 81 58 95 190 7 186 0 0 0 0 0 0 151 133 146 190 183 181 21 96 144 1 34 248 0 0 0 0 83 84 82 65 84 65 83 89 83 221 242 184 43 123 30 110 30 111 200 221 87 208 147 90 162 73 93 41 51 29 163 254 145 227 141 144 54 207 14 127 125 192 248 117 89 202 65 79 24 16 14 252 24 13 120 91 195 17 44 60 237 171 36 5 110 26 241 253 86 84 118 30 138 249 169 28 201 104 160 170 90 120 237 81 121 174 174 79 136 223 146 166 233 223 183 152 33 56 232 213 5 168 187 117 133 35 125 149 206 161 148 93 236 145 78 150 6 145 76 79 253 246 242 177 70 177 78 131 98 210 190 129 139 43 117 204 211 222 107 207 242 29 2 238 128 156 54 115 215 43 141 250 158 21 201 28 219 70 223 126 58 30 52 244 33 145 100 197 8 170 48 37 54 217 99 243 128 88 94 71 129 35 135 149 103 108 187 212 100 139 80 237 82 145 99 87 211 221 4 166 86 14 25 178 44 76 92 77 242 148 103 120 194 225 169 166 99 183 60 227 255 158 212 186 243 105 11 175 63 20 178 154 137 57 170 92 119 156 122 53 152 190 173 179 154 41 234 156 6 61 35 166 217 104 110 88 245 148 56 141 102 66 166 189 94 99 75 145 208 55 67 38 40 18 66 131 207 228 170 81 207 154 156 28 40 50 230 75 63 139 57 138 220 200 132 98 153 251 23 214 205 167 103 125 22 248 81 212 204 248 63 45 165 107 193 33 131 9 63 235 148 44 174 149 37 102 173 215 120 189 172 126 138 83 80 32 132 253 124 107 101 103 38 204 253 235 110 237 108 140 166 126 29 56 5 11 60 43 71 223 215 28 20 31 245 23 112 49 55 154 201 226 21 208 12 184 50 238 13 107 159 30 159 40 51 217 248 157 245 4 242 110 16 224 245 50 61 180 97 59 187 62 183 72 246 131 31 222 
Device reset. Read ended.
Writing collected data in 10...
9...8...7...6...5...4...3...2...1...Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending WRITE SCRATCHPAD(0x0F)
Setting write address
Begining write of collected data....
Starting at byte number 
0
127 165 211 203 231 31 187 198 128 18 205 137 228 187 177 94 55 108 148 7 68 37 128 164 167 78 246 138 15 176 177 36 Wrote this batch of 32 bytes
Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending READ SCRATCHPAD (0xAA)

123 165OK 147 195 69 31OK 179 70 128OK 18OK 205OK 9 228OK 179 145 30 55OK 100 148OK 7OK 68OK 36 128OK 164OK 163 78OK 212 138OK 15OK 32 177OK 36OK Authorization codes have been read.
Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending COPY SCRATCHPAD (0x55)
Sending AUTHORIZATION CODES (
0 0 31)Waiting 50ms for scratchpad to finish copying...
Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending WRITE SCRATCHPAD(0x0F)
Setting write address
Begining write of collected data....
Starting at byte number 
32
171 48 111 178 175 96 31 111 72 179 70 55 155 172 223 81 72 179 70 55 155 172 223 81 56 243 119 54 43 249 197 209 Wrote this batch of 32 bytes
Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending READ SCRATCHPAD (0xAA)

163 48OK 47 178OK 173 96OK 31OK 111OK 64 179OK 70OK 55OK 155OK 172OK 223OK 81OK 72OK 179OK 66 55OK 10 172OK 223OK 65 56OK 242 119OK 54OK 9 241 197OK 65 Authorization codes have been read.
Sending reset pulse NOW!
Presence pulse received, sending SKIP ROM CHECK (0xCC)
Sending COPY SCRATCHPAD (0x55)
Sending AUTHORIZATION CODES (
32 0 23)Waiting 50ms for scratchpad to finish copying...
Sending reset pulse NOW!

(Truncated due to post length limit)

If you'd like any more data on my setup that I haven't included here, please ask and I'll be happy to provide it! Or if you'd like me to clarify some of the code, I know it's in shambles. :stuck_out_tongue:

EEPROMsketchVolatile.ino (6.82 KB)

I have a small program that's meant to read the data off one chip

Are the Lays chips? I'm sure that Tim's Cascade chips don't have EEPROMs.

Perhaps, if you told us what kind of chips they are, we could help.

Come on now, no need to be mean to other users, sir. Just like I won't be mean to you for missing this line in my original posting. :slight_smile:

kataze:
I'm using a pair of DS2433 chips

OneWire ds(10);                    // OneWire bus on digital pin 6

Are you sure that this should not be 12 or -14?

You have a lot of Serial.print() statements, containing a lot if characters. You have a 512 byte buffer to store data in that read from the EEPROM.

I'd guess that you are running out of SRAM on the Arduino. Which version of the IDE are you using?

The original example sketch had it set to pin 6, but I was having trouble reading values on that, and changed to 10 which gave me valid data. I can give 12 and 14 a try if you think it will help. I'll try removing the serial statements as well, I guess I didn't consider the space they'd be taking up, I do have a lot.

I'm running Arduino 1.0 as my IDE, I don't have the computer in front of me right now, so I'm not sure what build it is or anything more specific at the moment :frowning:

I should also probably clarify that I'm not trying to write to the Arduino's EEPROM, but the DS2433.

The original example sketch had it set to pin 6, but I was having trouble reading values on that, and changed to 10 which gave me valid data. I can give 12 and 14 a try if you think it will help.

No, I don't think it will help. If there is going to be a useless comment, though, you should maintain it. Or delete it.

I'm running Arduino 1.0 as my IDE, I don't have the computer in front of me right now, so I'm not sure what build it is or anything more specific at the moment

I think that you remember having downloaded a release candidate version, since you don't get those from the Arduino site. Since you didn't even mention the possibility, we can safely assume that 1.0 from the Arduino site is what you are using.

I should also probably clarify that I'm not trying to write to the Arduino's EEPROM, but the DS2433.

Kind of obvious, since you don't need to specify a pin number to write to the internal EEPROM.

Perhaps the key to solving your problem is to write to and read from the external EEPROM in smaller chunks. Write to/read from 1/4 of the EEPROM, starting at the first address. Then, read/write the next 1/4, etc.

Before doing that, it might be useful to search for the FreeMemory function, and add some calls to that to your code, to see if running out of memory IS your problem.

PaulS:
No, I don't think it will help. If there is going to be a useless comment, though, you should maintain it. Or delete it.

Pardon me for mistaking your attempt at being clever for helpful advice.

PaulS:
I think that you remember having downloaded a release candidate version, since you don't get those from the Arduino site. Since you didn't even mention the possibility, we can safely assume that 1.0 from the Arduino site is what you are using.

A correct assumption indeed.

PaulS:
Kind of obvious, since you don't need to specify a pin number to write to the internal EEPROM.

You can never be too sure.

PaulS:
Perhaps the key to solving your problem is to write to and read from the external EEPROM in smaller chunks. Write to/read from 1/4 of the EEPROM, starting at the first address. Then, read/write the next 1/4, etc.

I've been writing in 32-byte chunks of the entire 512byte memory. I can try going smaller if you think it would help.

PaulS:
Before doing that, it might be useful to search for the FreeMemory function, and add some calls to that to your code, to see if running out of memory IS your problem.

I've added a few free memory calls before and after read/write operations. There is available space.

I've been writing in 32-byte chunks of the entire 512byte memory. I can try going smaller if you think it would help.

The code you have been posting may write 32 bytes at a time, but it writes them from the 512 byte array. Writing fewer bytes won't change the amount of memory the 512 byte array takes.

I've added a few free memory calls before and after read/write operations. There is available space.

Can you post the modified code, and sample output?

Whoops, it seems I uploaded a slightly older version of my code than intended. I had to write in a few changes from scratch as I can't find the most recent version. I had some much more consistent errors (only writing the first 32-bytes), and after tweaking the way the scratchpad is written, managed to copy it over. The fully working code is attached below, for anyone who may need it in the future.

EEPROMsketchNEW.ino (8.11 KB)