最近在学习三星的一款ARM7 S3C44B0X 过程中遇到一个问题,请各位能帮我一下:
(1)我用的网卡时CS8900-CQ3我现在需要读取它的ID码,我的硬件连接是网卡的地址线: SA0-SA19 其中只有SA8,SA9拉高,其余都为低电平,网卡接在我的主控S3C44B0X的BANK3区域,网卡的(SBHE)引脚和网卡的地址线(SA0)连接,网卡的地址线(SA0)和主控的地址线(ADDR1)连接。硬件就是这样的(3.3V供电)。下面是我的程序:
#include "44B0X.h"
#include "DEF.h"
// #define __BIG_ENDIAN 0 //所有模块都是用小端模式
#define CS8900_BUS16_0 ((vola
tile unsigned short *)0x06000300)
#define CS8900_BUS16_1 ((volatile unsigned short *)0x06000302)
#define CS8900_PPTR ((volatile unsigned short *)0x06000314) //(0x06000300 + (0x0A << 1) )
#define CS8900_PDATA ((volatile unsigned short *)0x06000318) //(0x06000300 + (0x0C << 1) )
#define PP_ChipID 0x0000 /* Chip identifier - must be 0x630E */
#define PP_ChipRev 0x0002 /* Chip revision, model codes */
unsigned short ChipID1 = 0;
unsigned short ChipID2 = 0;
unsigned short Read_1 = 0;
unsigned short Read_2 = 0;
unsigned short Read_3 = 0;
unsigned short Read_4 = 0;
unsigned short C_Read = 0;
unsigned int Read_Reg = 0;
/*************************************************************************
**函数名称: System_Init
**函数功能: 系统初始化
**入口参数: 无
**出口参数: 无
***************************************************************************/
void System_Init(void)
{
rSYSCFG = 0x00; // System Configuration
rNCACHBE0 = 0x00000000; // Non Cacheable Area 0
rNCACHBE1 = 0x00000000; // Non Cacheable Area 1
rSBUSCON = 0x80001B1B; // System Bus Control
rPLLCON = 0x5C081; // PLL Control Fpllo=(m*Fin)/(p*2^s) 50MHz主时钟
rCLKCON = 0x7FF8; // Clock Control
rCLKSLOW = 0x9; // Slow Clock Control
rLOCKTIME = 0xFFF; // PLL Lock Time Counter
}
/****************************************************/
void Port_Init(void)
{
//16bit data bus configuration
// PORT A GROUP
// 9 8 7 6 5 4 3 2 1 0
// A24 A23 A22 A21 A20 A19 A18 A17 A16 A0
// 0 1 1 1 1 1 1 1 1 1
rPCONA = 0x0ff; //A24不使用没有连接 不配置为地址线
// PORT B GROUP
// 10 9 8 7 6 5 4 3 2 1 0
// /CS5 /CS4 /CS3 /CS2 /CS1 GPB5 GPB4 /SRAS /SCAS SCLK SCKE
// EXT NIC USB IDE SMC NC NC Sdram Sdram Sdram Sdram
// ? ? ? ? ? Out Out ? ? ? ?
// 1 1 1 1 1 0 0 1 1 1 1
rPCONB = 0x14F; //nGCS3配置给网卡
// rPDATB = 0x7ff&~(1<<10);
// PORT C GROUP, BUSWIDTH=16
// 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
// NC NC Uart1 Uart1 NC NC NC NC NC NC NC NC out out out int
// ? ? ? ? ? ? ? ? ? ? ? ? * * * * *
// 00 00 11 11 00 00 01 01 00 00 00 00 01 01 01 00
rPDATC = 0xfc0F;
rPCONC = 0x45555554;
rPUPC = 0x7FFF; // PULL UP RESISTOR should be enabled to I/O
// PORT D GROUP
// BIT7 6 5 4 3 2 1 0
// VF OUT VLINE VCLK VD3 VD2 VD1 VD0
// 10 01 10 10 10 10 10 10
// rPDATD = 0xbf;
// rPCOND = 0x5555;
// rPUPD = 0x0;
// These pins must be set only after CPU's internal LCD controller is enable
// PORT E GROUP
// 8 7 6 5 4 3 2 1 0
// CODECLK Out Out Out TOUT1 Out(Beep) RXD0 TXD0 ?
// * * * * * * *
// 01 01 01 01 10 01 10 10 00
rPDATE = 0x1ff;
rPCONE = 0x15569;
rPUPE = 0x6;
// PORT F GROUP
// 8 7 6 5 4 3 2 1 0
// IISCLK IISDI IISDO IISLRCK Out Out Input IICSDA IICSCL
// * * * * * * * * *
// 100 100 100 100 01 01 00 10 10
rPCONF = 0x92555; //GPF8 = DIP4 // PF3:LED4 PF4:LED3 PF2:nWait
rPUPF = 0x1FF;
// PORT G GROUP
// 7 6 5 4 3 2 1 0
// INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0
// S3 S4 S5 S6 NIC IDE USB
// *
// 11 11 11 11 11 11 11 11
rPCONG = 0x1557;
rPUPG = 0xff; // should be enabled
rSPUCR = 0x4; // D15-D0 pull-up disable
rEXTINT = 0x22222022; //All EINT[7:0] will be falling edge triggered. [30:0]
}
static void Delay_ms(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
static void Delay_us(unsigned int dly)
{
while(dly--);
}
static void IcacheInit(void)//8K --RAM
{
int regSYSCFG = 0;
regSYSCFG = rSYSCFG;
regSYSCFG = 0x0;
rSYSCFG |= regSYSCFG; // System Configuration WE = 1
rNCACHBE0 = 0xC0000000; // Non Cacheable Area 0
rNCACHBE1 = 0x00000000; // Non Cacheable Area 1
}
static void Reg16_Busy(void)
{
unsigned short initd = 0;//寄存器16的寄存器号:0x0136;的第7位用于判忙延时。=1不忙
rPDATF |= (1 << 8); Delay_us(10); //Read_SBHE_H
rPDATF &= ~(1 << 8); Delay_us(10); //Read_SBHE_L
*CS8900_PPTR = 0x0000;
initd = *CS8900_PDATA;
while(!(initd & (1<< 7)));
}
/*************************************************************************
**函数名称: main
**函数功能:
**入口参数:
**出口参数:
***************************************************************************/
void sys_init(void)
{
rWTCON = 0;
IcacheInit();
rPLLCON = 0x5C081; // PLL Control Fpllo=(m*Fin)/(p*2^s) 50MHz=0x5C081 20MHz=0x20081
rCLKCON = 0x7FF8; // Clock Control
rCLKSLOW = 0x9; // Slow Clock Control
rLOCKTIME = 0xFFF; // PLL Lock Time Counter
}
int main(void)
{
sys_init(); //系统初始化
Port_Init(); //GPIO口初始化
rBWSCON &= ~(0xF << 12); //nGCS3=nUB/nLB(sSBHE)
rBWSCON |= (0xD << 12); //nWAIT,16-bit
rBANKCON3 = (0 << 13) | (3 << 11) | (7 << 8) | (1 << 6) | (0 << 4) | (3 << 2) | 0; //Bank3总线配置
Delay_ms(500); //等待复位10Ms
C_Read = *CS8900_BUS16_0;
C_Read = *CS8900_BUS16_1;
C_Read = *CS8900_BUS16_0;
C_Read = *CS8900_BUS16_1;
C_Read = *CS8900_BUS16_0;
rPDATE &= ~(1 << 6); //红色 报警灯
while(1)
{
C_Read = *CS8900_BUS16_0; Delay_us(10);
*CS8900_PPTR = 0x0000;
C_Read = *CS8900_BUS16_0; Delay_us(10);
ChipID1 = *CS8900_PDATA;
rPDATE &= ~(1 << 6); //红色 报警灯
}
}
0