Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

256kb SRAM interfacing code to LM3S3748 controller using SPI

Status
Not open for further replies.

seetaram

Newbie level 4
Joined
Oct 23, 2008
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
Hi i am interfacing 256SRAM (N25S830HA) to LM3S3748 controller using non spi port that means gpio port. Here i have to write spi driver using gpio pin (not inbuilt spi port). I have written code but after finishing writing then i will start to read then only 0 value coming. So i want to know exact procedure to write driver using gpio pin. If any one worked on this please give me the details and step to to write and read data from memory and clocking step also.
Thank you
 

have you refered the SPI specification before writing the driver?
Does your driver follows the timing requited by SPI standard and also required for the memory?
You can verify this first using DSO, before checking memory write and read.
One this is clear. Then check for the wave form details for write and read cycle in memory data sheet. and verify whether your driver is able to generate same cycles or not.
 

Hi,
Ya i have refereed SPI specification before writing the program. Based on SRAM timing requirement i developed my code like as follows and please what are the wrong in my code and if any changes is there please give me the solution.

1. Enabled GPIO pin as MOSI, MISO, CLK, CS
2. CS=0
CLK=0
CS=1
To write to SRAM
3. SPIWRITE(WRD_INSTR)
4. SPIWRITE(0x00)
5. SPIWRITE(0x00);
6. SPIWRITE('A')
7. CS=0
MOSI=0
CLK=0
CS=1
To read data from RAM
8. SPIWRITE(READ_INSTR)
9. SPIWRITE(0x00)
10. SPIWRITE(0x00)
11. data=SPI_READ()
12. CS=1


SPIWRITE( unsigned char b)
{
unsigned char m, i;
for(i=0;i<8;i++)
{
if(b!=0)
MOSI=1
else
MOSI=0;
CLK=1
CLK=0
b=m<<1;
} m=b;
}

unsigned char SPI_READ()
{
unsigned char i;
for(i=0;i<8;i++)
{
if(MISO)
b1=(b1 | 0x01);
else
a1=b1;
b1=b1<<1;
CLK=1
CLK=0
}
return a1;
}


Thank youi
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top