S3C2440A has 130 multi-functional input/output port pins and there are eight ports as shown below: - Port A(GPA): 25-output port - Port B(GPB): 11-input/out port - Port C(GPC): 16-input/output port - Port D(GPD): 16-input/output port - Port E(GPE): 16-input/output port - Port F(GPF): 8-input/output port - Port G(GPG): 16-input/output port - Port H(GPH): 9-input/output port - Port J(GPJ): 13-input/output port 端口控制描述 端口控制寄存器(GPACON-GPJCON) 端口數據寄存器(GPADAT-GPJDAT) 端口上拉寄存器(GPBUP-GPJUP) 復用控制寄存器 外部中斷控制寄存器 假設,有4個LED燈,分別接在GPF0~GPF3上,低電平點亮 GPF有7個I/O口,三組寄存器GPFCON,GPFDAT,GPFUP //包含頭文件區 #include "2440addr.h" //系統文件 #include "2440lib.h" #include "def.h" #include "uart.h" void Main(){ //步,設置系統時鐘 memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,1000); //調用2440lib.c中的函數 SetSysFclk(FCLK_200M);//設置系統時鐘為200M ChangeClockDivider(1,1);//設置分頻為1:2:4 CalcBusClk(); //計算總線頻率 //第二步:初始化串口 Uart_Select(0); Uart_Init(0,115200); //第三步:配置GPF寄存器 rGPFCON = (rGPFCON | 0xffff) & 0xffffff55; //設置GPF為輸出口 rGPFUP &= 0xfff0; //使能上拉 rGPFDAT = 0xff; //初始化 //第四步:進入大循環 while(1){ rGPFDAT = 0xFE; //點亮 } }
編譯工程,點擊工具欄上的【make】按鈕開始編譯,如果沒有錯誤,就可以下載到開發板上運行,這時,就需要使用AXD工具。點擊【Debug】工具按鈕,運行AXD。需要指定HJTAG工具連接到開發板上,選擇【Options】菜單下載的【ConfigureTarget】,在彈出的ChooseTarget對話框中添加HJTAG的配置文件(H-JTAG安裝目錄下的H-JTAG.dll文件),點擊【Configure】按鈕,完成H-JTAG的配置使用AXD進行調試時,在NandFlash中不應該有其他的程序,否則,會使運行不正常!應先擦除NandFlash。
在調試之前,應該對SDRAM進行配置,因為程序是要下載到內存中運行的,因此,首先需要對SDRAM進行正確配置,選擇【Options】菜單下的【Configure Interface】,在彈出的對話框中選擇【Session File】標簽頁,勾選【Run Configuration Script】復選框,加入2440init.txt配置腳本文件。重啟AXD如果電腦沒有并口,也可以使用J-Link連接到開發板。首先,需要安裝J-Link的驅動,然后添加J-Link的配置文件(JLinkRDI.dll),方法同上。