#define STSR_CSR (*(volatile uint32_t *)0xE000E010) #define STSR_RVR (*(volatile uint32_t *)0xE000E014) #define STSR_CRV (*(volatile uint32_t *)0xE000E018) #define STSR_CALIB (*(volatile uint32_t *)0xE000E01C) __attribute__((optimize("O2"))) static unsigned short measureCPUfreq (void) { uint16_t i; STSR_RVR = 0x00FFFFFF; //reloaded value STSR_CRV = 0x1; //reset the counter STSR_CSR = 0x5; for(i=0; i<64; i++) // 64 x 16 Mops { // Number of clock edge while(!(STSR_CSR&0x10000)); // 16 Mops } return (ANSW_OK); }