Go Down

Topic: Trouble with SPI read/write to 23K256 SRAM chip (SOLVED) (Read 2 times) previous topic - next topic

SurferTim

#15
Sep 28, 2013, 02:52 pm Last Edit: Sep 28, 2013, 02:59 pm by SurferTim Reason: 1
How do you have the 4050 connected? You should have the 4050 powered by 3.3v and only the SS, MOSI and SCK connected to the 4050. The 23K256 MISO line can go directly to the Arduino.

I see a lot of products use the 74LVC245 as a logic level converter now. It appears to be about 10 times faster than the 4050.

edit: The uSD card slot on the ethernet shield uses a 74LVC1G125DCK as a converter. It works good.

chrisharrington

Yes, I just have SS, MOSI, and SCK running through it, with 3.3v in on pin 1 and ground on 8. As far as I can tell from the datasheet, it appears that pins 3, 5, and 7 going down the left are in, while the corresponding out pins are 2, 4, and 6 respectively. I imagine it would be a problem if I had that wrong. Apparently these are not bidirectional, but I guess that doesn't matter for the 23K256, so long as I have it wired correctly.

SurferTim

That is correct. My only concern is the propagation delay of the 4050. 120ns is a bit slow for the Arduino. You might want to cut the SPI bus speed down considerably, just as a test. You can always set it back if it makes no difference.
Code: [Select]
SPI.setClockDivider(SPI_CLOCK_DIV32);


chrisharrington

Brilliant, that did it.

So,

1. I don't need a breakout board. Chips and jumper wires will do fine until if and when I make my own board for the project.
2. I definitely need to level shift faster than the 4050. You said the 74LVC245 is good? The whole point of the setup is the speed gain this potentially gives me so I can get the mp3 stream from ether to mp3 chip fast enough for it to play.

Do you know of any other fast level shifters off hand?

chrisharrington

And the serial output:

Code: [Select]
Byte write...
Byte read...
72
101
108
108
111
45

Byte write...
Byte read...
87
111
114
108
100
33
33

seq write...
seq read...
Hello world!!

Byte read at operator[]...
72
101
108
108
111

Random read/write...
41A7 0 0
3AF1 1 1
2CD9 2 2
C2A 3 3
3782 4 4
5AC8 5 5
ED8 6 6
9FE 7 7
2F43 8 8
44D 9 9
1898 A A
3C55 B B
128C C C
5BE2 D D
54B3 E E
3747 F F
3917 10 10
4111 11 11
4398 12 12
4954 13 13
2E2F 14 14
2B11 15 15
162D 16 16
B05 17 17
3258 18 18
66F5 19 19
16B 1A 1A
1DD6 1B 1B
7788 1C 1C
1D07 1D 1D
6499 1E 1E
3492 1F 1F
F48 20 20
5133 21 21
6E62 22 22
1441 23 23
4CF3 24 24
F0D 25 25
5023 26 26
6AE5 27 27
785F 28 28
3530 29 29
22D1 2A 2A
76C8 2B 2B
75ED 2C 2C
4561 2D 2D
680C 2E 2E
154B 2F 2F
2902 30 30
5435 31 31
39 32 32
5081 33 33
6484 34 34
25B8 35 35
6514 36 36
1BA2 37 37
339C 38 38
66B4 39 39
6E5A 3A 3A
1267 3B 3B
2C2A 3C 3C
34CA 3D 3D
5AE5 3E 3E
1248 3F 3F
49E9 40 40
20C5 41 41
5F1 42 42
22B0 43 43
56C4 44 44
1C15 45 45
2B8A 46 46
11E5 47 47
6A9B 48 48
784D 49 49
4339 4A 4A
75F6 4B 4B
7F7 4C 4C
26E8 4D 4D
4CA1 4E 4E
1005 4F 4F
6AD3 50 50
78FE 51 51
73ED 52 52
4DA5 53 53
38D5 54 54
60F3 55 55
1AD9 56 56
4CE4 57 57
3C5B 58 58
3BFA 59 59
546C 5A 5A
DC3 5B 5B
1151 5C 5C
73E2 5D 5D
1C20 5E 5E
1FAE 5F 5F
100C 60 60
1EE1 61 61
7D06 62 62
2698 63 63


Thanks for the help!!

SurferTim

I think Adafruit carries the 74LVC245. You should be able to get the 74LVC125 from any electronics distributor like Digi-Key or Mouser.

chrisharrington

Thanks, I'll give the 74LVC245 a shot because I can get it in a DIP package. I can only find the 74LVC125 in surface mount (I don't do surface mount yet).

SurferTim

You are welcome!  :)

If you would do me a favor now. When you get the new logic level converter, please post what SPI bus speed it will handle. The default is SPI_CLOCK_DIV4.


chrisharrington

I'll do that. I just ordered a few of those from RS (they ship next day here in Japan), so I should be testing them in the next couple of days.

SurferTim

#24
Sep 28, 2013, 04:32 pm Last Edit: Sep 28, 2013, 05:07 pm by SurferTim Reason: 1
Bear in mind, you can really improve performance of that SRAM by using the other modes of operation. Page 6 of the Microchip datasheet. Read about the page and sequential modes. That should just about double the R/W speed.
http://ww1.microchip.com/downloads/en/DeviceDoc/22100E.pdf

edit: My maths sucks today. Make that almost 4 times faster.
One byte instruction - two bytes address - one data byte
One byte instruction - two bytes address - one data byte
One byte instruction - two bytes address - one data byte
One byte instruction - two bytes address - one data byte
versus
One byte instruction - two bytes address - 1st data byte - 2nd data byte - 3rd data byte - 4th data byte - ...

chrisharrington

Hi,

My 74LVC245 chips arrived today, so I tested them out. The sketch now appears to work at all speeds, from SPI_CLOCK_DIV64 up to SPI_CLOCK_DIV2. However, I was getting some strange behavior for a few runs where I was getting the correct results for the sequential and random tests in the sketch, but the single byte read/write was getting garbled. That issue simply disappeared after repeated several times, after which retesting at each speed showed no errors. Maybe these chips just need to warm up !? Very strange.

Also, as an aside, the posts where people use these level shifters with Arduino don't seem to mention this, and get away with not doing it, but I found that the warning in the data sheet of requiring all unused inputs being tied to Vcc or GND is a *requirement* (the 4050 datasheet has the same warning). If I don't do that, then I get the exact same problem for which I originally made this post for. That suggests that level shifter chips can have minor differences in performance between versions or even package formats, and that the faulty boards were designed using a chip that worked when certain precautions were ignored, but implemented with a version of the chip that was more finicky. Just a wild guess by a novice, anyway.

SurferTim

Quote
Also, as an aside, the posts where people use these level shifters with Arduino don't seem to mention this, and get away with not doing it, but I found that the warning in the data sheet of requiring all unused inputs being tied to Vcc or GND is a *requirement* (the 4050 datasheet has the same warning). If I don't do that, then I get the exact same problem for which I originally made this post for.

That will be your duty here now. Remind those who use these to not leave unused inputs floating. There could be some devices that are currently having problems due to this omission.

I probably should have mentioned this, but it has been a long while since I used a line buffer or logic level converter, and I forgot how important that is. Thanks for reminding me.  :)

chrisharrington

I notified the manufacturer as well, though I assume they probably have a (far) better idea of what was wrong with their boards than I do.

Go Up