cup----LPC2214 FLASH----SST 39VF6401B(4M*16BIT) CUP的A20:1接到FLASH,tool----keil IDEv3 uclinux
我想PINSEL2 BCFG0 配置应该没问题:
开CS,OE,BLS3:0,D31:0引脚功能;开ADDR23:2引脚功能;开ADDR0引脚功能,本程序只用到A20:1,此脚也可以不用;把空闲周期(两次读或写之间的间隔)开到最大;把读周期开到最大;设置成无字节选择;存储器不写保护;存储器是脉冲类型;数据总线宽度为16bit
访问外部falsh是通过指针,如下
for(I=0;I <100;I++)
{
dd=0x80000000+I*2;
printf("*dd=%l",*dd);
}
结果是读到的都是0XFFFF,写也不成功,上面的代码我也不知道对不对,能不能这样访问,因为正规的代码没看到过,我一点底都没有。哪位大大教教我啊。
下面我贴上全部的文件:#include <head.H>
//BM-存储器是不是脉冲类型不确定,存储器是SST 39VF640(4M*16BIT)
//RBLE 这个不确定
//WP 不确定
//最好有EMC运行原理哦
/*configeration PINSEL2 to EMC */
#define BUSANDCTL_0 !(1 < <4)//开CS,OE,BLS3:0,D31:0引脚功能
#define BUSANDCTL_1 (1 < <5) //开CS,OE,BLS3:0,D31:0引脚功能
#define WE (1 < <8)//开WE 引脚功能
#define A0 (1 < <23)//开ADDR0引脚功能,本程序只用到A20:1,此脚也可以不用
#define A1 (1 < <24)//开ADDR1引脚功能,本程序只用到A20:1,此脚也可以不用
#define A23_2 (111 < <25)//开ADDR23:2引脚功能
/*configeration BCFG0 */
#define BCFG0 (*((volatile unsigned long *) 0xFFE00000))
#define IDCY 0X0F < <0//把空闲周期(两次读或写之间的间隔)开到最大
#define WST1 (0X1F < <5)//把读周期开到最大
#define RBLE ~(1 < <10)//设置成无字节选择
#define WST2 0X1F < <11//把读访问开到最大
#define WP ~(1 < <26)//存储器不写保护
#define BM 1 < <27//存储器是脉冲类型
//#define BM !(1 < <27)//存储器是脉冲类型
#define MW_0 1 < <28 //数据总线宽度为16bit
#define MW_1 ~(1 < <29)//数据总线宽度为16bit
//CS0, WE, OE, D0-D15 A1-A20
//P1.0 P3.27 P1.1 P2.0-P2.15 P3.1-P3.20
/****************/
/* main program */
/****************/
extern void putString(char* s);
int main (void) { /* execution starts here */
int I;
uint16_t *dd;
uint32_t FF;
char s[]="1234567\n";
/* initialize the serial interface */
PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 90; /* 9600 Baud Rate @ 11.059MHz extern Clock */
U0DLM = 0;
U0LCR = 0x03; /* DLAB = 0 */
printf("initialization \n");
//PINSEL2 =PINSEL2|WE|A0|A1|A23_2&BUSANDCTL_0;
//PINSEL2 =PINSEL2|WE;
PINSEL2=0x0f81491F;
printf("start\n");
//BCFG0=BCFG0|(IDCY|WST1|WST2|BM|MW_0)&(RBLE&WP&MW_1);
printf("*dd=%l",FF);
BCFG0=0x1000ffef;
for(I=0;I <100;I++)
{
dd=0x80000000+I*2;
printf("*dd=%l",*dd);
}
while (1){ /* An embedded program does not stop and */
//putString(s);
//printf("1234567890\n");
; /* ... */ /* never returns. We've used an endless */
} /* loop. You may wish to put in your own */
}