📄 main.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : main.c
//* Object : main application written in C
//* Creation : HPP 06/JUN/2003
//*----------------------------------------------------------------------------
#include "AT91RM9200.h"
#include "lib_AT91RM9200.h"
#include "target.h"
// #include "mmu.h"
extern void AT91F_DBGU_Printk(char *);
extern void benchmark(void);
static char atmel_header[]=
{
"\n\r *** ATMEL Bench ***\n\r"
"Copyright (C) 2003 ATMEL Corporations\n\r"
};
//*----------------------------------------------------------------------------
//* Function Name : MCKClock
//* Object : Get Clock information
//* Input Parameters : PLLA : Pll value
//* Output Parameters : mck peripheral clock
//*----------------------------------------------------------------------------
unsigned int MCKClock (unsigned int PLLA)
{
unsigned int dummy;
unsigned int mul,div,mdiv;
unsigned int pmck,mck ;
dummy = ((*AT91C_CKGR_MCFR) & AT91C_CKGR_MAINF);
//* Slow Clock (SLCK), typically at 32.768 Hz,
dummy = dummy * (32768/16);
mul = (PLLA >> 16) & 0x7FF;
div = PLLA & 0xFF;
mdiv = (( *AT91C_PMC_MCKR) >> 8) & 3;
pmck =( (mul+1)*dummy/div);
mck = pmck/(mdiv+1);
return mck;
}
//*----------------------------------------------------------------------------
//* Function Name : InfoClock
//* Object : Print Clock information
//* Input Parameters : PLLA : Pll value
//* Output Parameters : mck peripheral clock
//*----------------------------------------------------------------------------
unsigned int InfoClock (unsigned int PLLA)
{
unsigned int mdiv,pmck,mck ;
char message [50];
//* Get
sprintf((char*) message,"PLLA 0x%08X \n\r",PLLA);
AT91F_DBGU_Printk((char*)message);
mck = MCKClock ( PLLA);
mdiv = (( *AT91C_PMC_MCKR) >> 8) & 3;
pmck = mck*(mdiv+1);
sprintf((char*) message,"Processor clock % d \n\r",pmck);
AT91F_DBGU_Printk((char*)message);
sprintf((char*) message,"Peripheral clock %d \n\r",mck);
AT91F_DBGU_Printk((char*)message);
return mck;
}
//*----------------------------------------------------------------------------
//* Function Name : measure
//* Object : Print Clock information
//* Input Parameters : PLLA
//* Output Parameters : mck peripheral clock
//*----------------------------------------------------------------------------
void measure(char * cache)
{
char message[80];
//* External SDRM
AT91F_DBGU_Printk("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\r");
sprintf(message,"CPU: ATMEL AT91RM9200 Board AT91RM9200-DK/60MHz SDRAM %s \n\r",cache);
AT91F_DBGU_Printk(message);
AT91F_DBGU_Printk("Compiler:Green Hills , runtime optimized speed\n\r");
AT91F_DBGU_Printk("OS: no operating system\n\r");
//* Call bench from IXXAT Automation GmbH
benchmark();
//* Internal ram
AT91F_DBGU_Printk("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\r");
sprintf(message,"CPU: ATMEL AT91RM9200 Board AT91RM9200-DK/60MHz Internal RAM%s \n\r",cache);
AT91F_DBGU_Printk(message);
AT91F_DBGU_Printk("Compiler:Green Hills , runtime optimized speed\n\r");
AT91F_DBGU_Printk("OS: no operating system\n\r");
AT91F_DBGU_Printk("Internal RAM:\n\r");
//* Call bench from IXXAT Automation GmbH
benchmark_int();
}
//*----------------------------------------------------------------------------
//* \fn main
//* \brief This function is main entry point
//*----------------------------------------------------------------------------
int main()
{
AT91F_DBGU_Printk(atmel_header);
InfoClock((*AT91C_CKGR_PLLAR));
// First, enable the clock of the PIOB
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<<AT91C_ID_PIOB ) ;
// then, we configure the PIO Lines corresponding to LED1 to LED8
// to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
AT91F_PIO_CfgOutput( AT91C_BASE_PIOB, LED_MASK ) ;
AT91F_ResetICache();
AT91F_ResetDCache();
AT91F_DisableICache();
AT91F_DisableDCache();
measure("Disabel cahe ");
AT91F_EnableICache();
measure("Enable ICache");
AT91F_EnableDCache();
measure("Enable DCache");
AT91F_DBGU_Printk("----------------- End bench\n\r");
while (1){};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -