union bsc_addr1 { /* union RAMCR */
unsigned short WORD; /* Byte Access */
struct {
unsigned char B15:1; /* Bit 15 */
unsigned char B14:1; /* Bit 14 */
unsigned char B13:1; /* Bit 13 */
unsigned char B12:1; /* Bit 12 */
unsigned char B11:1; /* Bit 11 */
unsigned char B10:1; /* Bit 10 */
unsigned char B9 :1; /* Bit 9 */
unsigned char B8 :1; /* Bit Access */
unsigned char B7 :1; /* Bit 7 */
unsigned char B6 :1; /* Bit 6 */
unsigned char B5 :1; /* Bit 5 */
unsigned char B4 :1; /* Bit 4 */
unsigned char B3 :1; /* Bit 3 */
unsigned char B2 :1; /* Bit 2 */
unsigned char B1 :1; /* Bit 1 */
unsigned char B0 :1; /* Bit 0 */
} BIT; /* */
};
#define BSC_ADDR (*(volatile union bsc_addr1 *)0x08000002)
定义了外扩的地址
#define CS_RAM PA.DR.BIT.B6
#define WR PA.DR.BIT.B12
#define WRH PA.DR.BIT.B13
#define RD PA.DR.BIT.B14
void main(void)
{
RD=1;
WR=1;
WRH=1;
CS_RAM=1;
for(n=0;n<100;n++){nop();}
PC.DR.WORD.L=0X0002;
CS_RAM=0;
while(1)
{
RD=0;
nop();
i=BSC_ADDR.WORD;
nop();
nop();
nop();
RD=1;
nop();
nop();
WR=0;
WRH=0;
nop();
BSC_ADDR.WORD=m;
m++;
nop();
nop();
nop();
WR=1;
WRH=1;
nop();
nop();
PE.DR.BIT.B2=1;
}
}
我的PFC管脚控制都选择了总线模式了,可就是读写不成功。读的话在变量i=8,没有其他变化。
疑问:
1.是不是总线地址定义的不对,要怎么定义 ?
2.读写方式是不是有问题?小弟研究了几天了,无耐,求大虾帮助~~~~ |