I bought a STM32 Primer kit and would like to bench it, in order to know how faster is the Cortex M3. I have installed Ride7 and have ported dhrystone2. I am using the SysTick functions to measure the elapsed time and have initialized the application by:
/* System Clocks Configuration */ RCC_Configuration();
/* Select HSE as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE);
/* Wait till HSE is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x04) { } }
I am using the 12MHz clock and did not set wait states to the flash (I assume that there are 0 WS by default). I would like to bench without wait-state, anyway, in order to check that I can achieve 1.25DMips / MHz, as described in the datasheet. Is there any wrong things in my configuration?
I am using Ride7 IDE v7.01.0002 and RKitARM for RIDE7 v1.03.0003. I am using the sysTick and the measure time is short enough so that there is no underflow on the 24-bit timer. I will make a zip of the package when I will have time.
More news: I have checked with a scope, and the measured time perfectly matches the time measured by the SysTick. So, I am pretty confident that I am using 12MHz and that my measure function works.
Here is the main.c: (BTW, is it possible to attach files on the forum?)
/******************** (C) COPYRIGHT 2007 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Date First Issued : 02/05/2007 * Description : Main program body ******************************************************************************** * History: * 04/02/2007: V0.2 * 02/05/2007: V0.1 ******************************************************************************** * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/
/* Includes ------------------------------------------------------------------*/ #define _SysTick #include "stm32f10x_lib.h"
/* Select HSE as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE);
/* Wait till HSE is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x04) { } }
/******************************************************************************* * Function Name : NVIC_Configuration * Description : Configures Vector Table base location. * Input : None * Output : None * Return : None *******************************************************************************/ void NVIC_Configuration(void) { #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif }
#ifdef DEBUG /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert error has occurred. * Input : - file: pointer to the source file name * - line: assert error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(u8* file, u32 line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */ while (1) { } } #endif
/******************************************************************************* * Function Name : Delay * Description : Inserts a delay time. * Input : nCount: specifies the delay time length. * Output : None * Return : None *******************************************************************************/ void Delay(vu32 nCount) { for(; nCount!= 0;nCount--); }
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
What fault are you talking about? BTW you said you wanted to compare my code with your code, that means that have ported dhrystone2 too? What score did you get?
khauer :
But what about the function main_dryhstone()??
Is it possible to post it too. Or where could I get that code.
I only hear about that benchmark code, but I never seen one before.
Thanks for help Klaus
The main_dhrystone is just the main function of dhrystone, which has been renammed into main_dhrystone.
Here is the code: /* This is a MODIFIED version of the Dhrystone 2.1 Benchmark program.
The only changes which have been made are: 1) the 'old-style' K&R function declarations have been replaced with 'ANSI-C-style' function declarations (in dhry_1.c and dhry_2,c), and 2) function prototypes have been added (in dhry.h)
These changes allow an ANSI-C compiler to produce more efficient code, with no warnings. */
/* **************************************************************************** * * "DHRYSTONE" Benchmark Program * ----------------------------- * * Version: C, Version 2.1 * * File: dhry_1.c (part 2 of 3) * * Date: May 25, 1988 * * Author: Reinhold P. Weicker * **************************************************************************** */
#include "dhry.h" #include "util.h"
Rec_Pointer Ptr_Glob, Next_Ptr_Glob; int Int_Glob; Boolean Bool_Glob; char Ch_1_Glob, Ch_2_Glob; int Arr_1_Glob [50]; int Arr_2_Glob [50] [50];
#ifndef REG Boolean Reg = false; #define REG /* REG becomes defined as empty */ /* i.e. no register variables */ #else Boolean Reg = true; #endif
/* variables for time measurement: */
#ifdef TIMES struct tms time_info; extern int times (void); /* see library function "times" */ #define Too_Small_Time (2*HZ) /* Measurements should last at least about 2 seconds */ #endif #ifdef TIME extern long time(long *); /* see library function "time" */ #define Too_Small_Time 2 /* Measurements should last at least 2 seconds */ #endif #ifdef MSC_CLOCK extern clock_t clock(void); #define Too_Small_Time (2*HZ) #endif
//#define Too_Small_Time=100;
long Begin_Time, End_Time, User_Time;
long Microseconds, Dhrystones_Per_Second, Vax_Mips;
//float Microseconds, //Dhrystones_Per_Second;
/* end of variables for time measurement */
Rec_Type next; Rec_Type first;
unsigned char gstring[80];
long time(long *);
int main_dhrystone ( void ) //formerly main() { One_Fifty Int_1_Loc; REG One_Fifty Int_2_Loc; One_Fifty Int_3_Loc; REG char Ch_Index; Enumeration Enum_Loc; Str_30 Str_1_Loc; Str_30 Str_2_Loc; REG int Run_Index; REG int Number_Of_Runs;
/* Procedure for the assignment of structures, */ /* if the C compiler doesn't support this feature */ #ifdef NOSTRUCTASSIGN memcpy (d, s, l) register char *d; register char *s; register int l; { while (l--) *d++ = *s++; } #endif