I have got around to setting up a breadboard with a 32K x 8 SRAM chip (W24257).
Of the 13 address lines, I have interfaced 8 of them (thus I can only use 256 bytes of the 32K) and tied the others low. 6 of the IO pins are connected to PORTB of a 16F628 while the remaining 2 are connected to PORTA. /WE and /OE are also connected to PORTA while /CS is grounded via a resistor.
I have managed to get a program on the PIC which receives a serial byte from a PC which specifies a SRAM address. The PIC then shifts this address though the shift-register onto the address pins. Anotehr byte is then sent from the PC which is a data byte and this is placed on the data lines. The program then configures the control lines and then attempts to read the data back from the SRAM chip and serially transmit the data back to the PC.
No luck, however...
Through debugging, I have determined that address data is correctly received by the PIC and correctly placed on the address lines by the shift-register.
My question comes about how to configure the control lines to write to the SRAM, and then later, how to configure them to get the data back out.
After shfting out the address, my current program configures the lines as follows:
1) Set /OE high
2) Set /WE low
3) Place data onto IO lines
4) Set /WE high
5) Set /OE low
This is based on my interpretation of "Write Cycle 1" (refer pg. 7), as described in the Winbond datasheet for the device: <A href='http://www.datasheetcatalog.com/datasheets_pdf/W/2/4/2/W24257A-12.shtml' Target=_Blank>External Web Link</a>.
The read part of the program is as such:
1) Set /WE high
2) Set /OE low
3) Read data from IO lines
4) Set /OE high
5) Set /WE low
This is based on my interpretation of "Read Cycle 3" (refer pg. 6), again, as described in the Winbond datasheet for the device. Have added the /WE controls, though as logic would have my set them accordingly, anyhow. Albeit it is not in the timing diagram, it is mentioned in the datasheet's "Truth Table" (refer pg. 2).
The data comes back to my PC corrupt, however. Examination of the binary equivalent of the ASCII characters that are returned show no common errors.
I suspect a few things. Most suspect is my interpretation of the timing diagrams for the read/write cycles. Am I controlling these lines correctly? In the right order? Of the right levels? I can only assume that at 4MHz, each instruction takes 100ns - much longer than any time parameter of the device, although have allowed for some idle cycles just in case.
the second suspect is that the chip is faulty but I will try and get a replacement tomorrow (or ASAP). None the less, I do not suspect this nearly as much as the way I am controlling my control lines.
Any help is appreciated...
If needed, I can also post the program but I have decided not to unless it is requested becuase it may cause more confusion, especially due to its long size. It is <i>quite </i> well documented (in my opinion), however, so feel free to ask for it.
<b><i>ylp88 </b> </i>
Of the 13 address lines, I have interfaced 8 of them (thus I can only use 256 bytes of the 32K) and tied the others low. 6 of the IO pins are connected to PORTB of a 16F628 while the remaining 2 are connected to PORTA. /WE and /OE are also connected to PORTA while /CS is grounded via a resistor.
I have managed to get a program on the PIC which receives a serial byte from a PC which specifies a SRAM address. The PIC then shifts this address though the shift-register onto the address pins. Anotehr byte is then sent from the PC which is a data byte and this is placed on the data lines. The program then configures the control lines and then attempts to read the data back from the SRAM chip and serially transmit the data back to the PC.
No luck, however...
Through debugging, I have determined that address data is correctly received by the PIC and correctly placed on the address lines by the shift-register.
My question comes about how to configure the control lines to write to the SRAM, and then later, how to configure them to get the data back out.
After shfting out the address, my current program configures the lines as follows:
1) Set /OE high
2) Set /WE low
3) Place data onto IO lines
4) Set /WE high
5) Set /OE low
This is based on my interpretation of "Write Cycle 1" (refer pg. 7), as described in the Winbond datasheet for the device: <A href='http://www.datasheetcatalog.com/datasheets_pdf/W/2/4/2/W24257A-12.shtml' Target=_Blank>External Web Link</a>.
The read part of the program is as such:
1) Set /WE high
2) Set /OE low
3) Read data from IO lines
4) Set /OE high
5) Set /WE low
This is based on my interpretation of "Read Cycle 3" (refer pg. 6), again, as described in the Winbond datasheet for the device. Have added the /WE controls, though as logic would have my set them accordingly, anyhow. Albeit it is not in the timing diagram, it is mentioned in the datasheet's "Truth Table" (refer pg. 2).
The data comes back to my PC corrupt, however. Examination of the binary equivalent of the ASCII characters that are returned show no common errors.
I suspect a few things. Most suspect is my interpretation of the timing diagrams for the read/write cycles. Am I controlling these lines correctly? In the right order? Of the right levels? I can only assume that at 4MHz, each instruction takes 100ns - much longer than any time parameter of the device, although have allowed for some idle cycles just in case.
the second suspect is that the chip is faulty but I will try and get a replacement tomorrow (or ASAP). None the less, I do not suspect this nearly as much as the way I am controlling my control lines.
Any help is appreciated...
If needed, I can also post the program but I have decided not to unless it is requested becuase it may cause more confusion, especially due to its long size. It is <i>quite </i> well documented (in my opinion), however, so feel free to ask for it.
<b><i>ylp88 </b> </i>