昨天终于把cf卡和up3板子连接的小板子做出来了
我用了up3板子上自带的那个cf测试程序
可是测试的时候结果就一“|”从右到左的晃动
没有其他东西
不知道为什么
程序如下:
#include
#include "io.h"
#include
int main()
{
unsigned int i, count, seldrv, present, pwr_on;
unsigned short data[2055];
unsigned long j;
unsigned char st_com,sel_drive;
#define CF_PRESENCE_CHK_REG_ADDRESS 0x00000880
#define CF_POWER_ON_REG_ADDRESS 0x00000890
#define CF_DATA_REG_ADDRESS 0x06000000
#define CF_ERROR_REG_ADDRESS 0x06000004
#define CF_SEC_CNT_REG_ADDRESS 0x06000008
#define CF_SEC_NO_REG_ADDRESS 0x0600000C
#define CF_CYL_L_REG_ADDRESS 0x06000010
#define CF_CYL_H_REG_ADDRESS 0x06000014
#define CF_SELECT_DRIVE_REG_ADDRESS 0x06000018
#define CF_STATUS_CMD_REG_ADDRESS 0x0600001C
#define CF_ALT_STATUS_REG_ADDRESS 0x06000038
#define OFFSET 0x00000000
unsigned short result=0;
//--------------------------------------------------------------
//Copact FLash presence cheching
//--------------------------------------------------------------
present =IORD(CF_PRESENCE_CHK_REG_ADDRESS,OFFSET);
if(present != 0)
{
printf("Waiting for the Compact Flash Card to be inserted ......\n");
}
while(present != 0)
{
present =IORD(CF_PRESENCE_CHK_REG_ADDRESS,0);
printf("");
}
printf("\n\nCompact Flash is detected ......\n\n\n");
//Power the device
IOWR(CF_POWER_ON_REG_ADDRESS,OFFSET,0x00000001);
while(1)
{
printf("\n*************** What do u want to do *****************\n");
printf(" \n");
printf("(1) : Get Device info \n");
printf("(2) : Removing the Compact Flash & Exit the Application \n");
printf("\n");
printf("********************************************************\n");
printf(" Enter your selection No:");
scanf("%d", &count);
switch(count)
{
case 1:
IOWR_8DIRECT(CF_STATUS_CMD_REG_ADDRESS,OFFSET,0xEC);
//Wait untile device ready bit not set
st_com =IORD_8DIRECT(CF_STATUS_CMD_REG_ADDRESS,OFFSET);
while((st_com&0x08)!=0x08)
{
st_com =IORD_8DIRECT(CF_STATUS_CMD_REG_ADDRESS,OFFSET);
}
printf("CF_STATUS_CMD_REG_ADDRESS = %x\n", st_com);
for(i=0;i<256;i++)
{
data = IORD_16DIRECT(CF_DATA_REG_ADDRESS,OFFSET);
}
for(i=0;i<256;i++)
{
printf("Word %d %04x\n",i,data);
}
break;
case 2:
IOWR(CF_POWER_ON_REG_ADDRESS,OFFSET,0x00000000);
printf(" \n\n --------------------------------------------\n");
printf(" Now its safe to remove the CompactFlash Card\n");
printf(" --------------------------------------------\n\n");
exit(0);
default:
//exit(0);
break;
}
}
return 0
大家知道有个system.h文件里面#define好多数
其中cf的定义了ctl和ide的base
“
#define CF_DATA_REG_ADDRESS 0x06000000
#define CF_ERROR_REG_ADDRESS 0x06000004
#define CF_SEC_CNT_REG_ADDRESS 0x06000008
#define CF_SEC_NO_REG_ADDRESS 0x0600000C
#define CF_CYL_L_REG_ADDRESS 0x06000010
#define CF_CYL_H_REG_ADDRESS 0x06000014
#define CF_SELECT_DRIVE_REG_ADDRESS 0x06000018
#define CF_STATUS_CMD_REG_ADDRESS 0x0600001C
#define CF_ALT_STATUS_REG_ADDRESS 0x06000038
#define OFFSET 0x00000000”
难道是这里需要改动吗 |