Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
test.c
Upload User: yzchenlin
Upload Date: 2022-03-09
Package Size: 712k
Code Size: 3k
Category:
ARM-PowerPC-ColdFire-MIPS
Development Platform:
C/C++
- //=======================================
- // File Name : test.c
- // Function : C语言主程序
- // History : 2007 02 14
- //=======================================
- //2410各寄存器的地址
- // CLOCK MANAGEMENT
- #define rMPLLCON (*(volatile unsigned *)0x4c000004) //MPLL Control
- #define rCLKDIVN (*(volatile unsigned *)0x4c000014) //Clock divider control
- // WATCH DOG TIMER
- #define rWTCON (*(volatile unsigned *)0x53000000) //Watch-dog timer mode
- #define rWTDAT (*(volatile unsigned *)0x53000004) //Watch-dog timer data
- #define rWTCNT (*(volatile unsigned *)0x53000008) //Eatch-dog timer count
- // I/O PORT
- #define rGPBCON (*(volatile unsigned *)0x56000010) //Port B control
- #define rGPBDAT (*(volatile unsigned *)0x56000014) //Port B data
- #define rGPBUP (*(volatile unsigned *)0x56000018) //Pull-up control B
- #define FCLK 202800000
- #define PCLK (202800000/4)
- static int delayLoopCount = FCLK/10000/10;
- void Delay(int time);
- void Led_Display(int data);
- void ChangeMPllValue(int m,int p,int s);
- void ChangeClockDivider(int hdivn,int pdivn);
- void testMain(void)
- {
- ChangeClockDivider(1,1); // 1:2:4
- ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz
- Delay(0);
- while(1)
- {
- Led_Display(1);
- Delay(500);
- Led_Display(0);
- Delay(500);
- }
- }
- void Delay(int time)
- {
- int i,adjust=0;
- if(time==0)
- {
- time = 200;
- adjust = 1;
- delayLoopCount = 400;
- rWTCON = ((PCLK/1000000-1)<<8)|(2<<3);
- rWTDAT = 0xffff; //for first update
- rWTCNT = 0xffff; //resolution=64us @any PCLK
- rWTCON = ((PCLK/1000000-1)<<8)|(2<<3)|(1<<5); //Watch-dog timer start
- }
- for(;time>0;time--)
- for(i=0;i<delayLoopCount;i++);
- if(adjust==1)
- {
- rWTCON = ((PCLK/1000000-1)<<8)|(2<<3); //Watch-dog timer stop
- i = 0xffff - rWTCNT; //1count->64us, 200*400 cycle runtime = 64*i us
- delayLoopCount = 8000000/(i*64); //200*400:64*i=1*x:100 -> x=80000*100/(64*i)
- }
- }
- void Delay1us(int time)
- {
- // resolution of time is 100us/100=1us.
- int delayLoop = FCLK/10000/10/100;
- int i;
- for(;time>0;time--)
- for(i=0;i<delayLoop;i++);
- }
- //========================[ BOARD LED ]=============================
- void Led_Display(int data)
- {
- rGPBDAT = (rGPBDAT & ~(0xf<<7)) | ((~data & 0xf)<<7);
- }
- //========================[ MPLL ]==================================
- void ChangeMPllValue(int mdiv,int pdiv,int sdiv)
- {
- rMPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;
- }
- //========================[ HCLK, PCLK ]============================
- void ChangeClockDivider(int hdivn,int pdivn)
- {
- rCLKDIVN = (hdivn<<1) | pdivn;
- }