#include "config.h"
#define uint unsigned int
#define uchar unsigned char
//#define SRAM_ADDR (uint16 *)0x80000000 //SRAM的起始地址分配在BANK0
#define SRAM_ADDR 0x80000000
//由于BS62LV16008001的A0与LPC2214的A1相连,所以addr要左移一位
//#define GetAddr(addr) (volatile uint16 *)(SRAM_ADDR|(addr<<1))
#define LED 0x000f0000
//#define
uint8 a=0;
void delay_ms(uint z)
{
uint x,y;
for(x=3000;x>0;x--)
for(y=z;y>0;y--);
}
void sram_init()
{
PINSEL2=0x0e000020; //WE OE CS0使能
BCFG0=0x0200182f; //存储器组配置寄存器
PINSEL2=PINSEL2&0xfffffff7; //将P1.16-P1.25设置为GPIO口
IO1DIR=LED; //将P1.16-1.19设置为输出端
IO1SET=LED;
}
void write_data(uint32 Addr, uint8 data)
{
volatile uint16 *ip;
ip=(volatile uint16 *)(SRAM_ADDR|Addr);
*ip=data;
}
uchar read_data(uint32 Addr)
{
uchar k;
volatile uint16 *ip;
ip=(volatile uint16 *)(SRAM_ADDR|Addr);
k=*ip;
return(k);
}
int main()
{
sram_init();
write_data(0x0,0x01);
delay_ms(5);
a=read_data(0x0);
while(1)
{
if(a==0x01)
{
IO1SET=LED;
}
else
{
IO1CLR=LED;
}
}
return(0);
}
这是我的程序,不知道哪错了,我用示波器量了OE WE BSL0信号还是高电平,我也配置了,不知道什么原因,求高手帮忙。。坐等啊。。哎。。等了一天了。。 |