
RunCoreMark on STM32F091
Fork of ClockControl by
main.cpp@2:6a9131b3df01, 2015-09-03 (annotated)
- Committer:
- Simon_mbed
- Date:
- Thu Sep 03 09:26:56 2015 +0000
- Revision:
- 2:6a9131b3df01
- Parent:
- 0:b5d3bd64d2dc
Run OK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
no2chem | 0:b5d3bd64d2dc | 1 | #include "mbed.h" |
no2chem | 0:b5d3bd64d2dc | 2 | #include "ClockControl/ClockControl.h" |
no2chem | 0:b5d3bd64d2dc | 3 | #include "CoreMark/core_portme.h" |
no2chem | 0:b5d3bd64d2dc | 4 | |
no2chem | 0:b5d3bd64d2dc | 5 | int main() { |
no2chem | 0:b5d3bd64d2dc | 6 | |
no2chem | 0:b5d3bd64d2dc | 7 | printf("mbed Clock Control test\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 8 | printf("(c) 2015 Simon_mbed\r\n"); |
no2chem | 0:b5d3bd64d2dc | 9 | |
Simon_mbed | 2:6a9131b3df01 | 10 | // unsigned short newM = 12; |
Simon_mbed | 2:6a9131b3df01 | 11 | // unsigned short newN = 1; |
no2chem | 0:b5d3bd64d2dc | 12 | |
Simon_mbed | 2:6a9131b3df01 | 13 | // printf("Value of M? (default = 12):\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 14 | // scanf("%d", &newM); |
Simon_mbed | 2:6a9131b3df01 | 15 | // |
Simon_mbed | 2:6a9131b3df01 | 16 | // printf("Value of N? (default = 1):\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 17 | // scanf("%d", &newN); |
no2chem | 0:b5d3bd64d2dc | 18 | |
Simon_mbed | 2:6a9131b3df01 | 19 | // setSystemFrequency(0x3, 0x1, newM, newN); |
no2chem | 0:b5d3bd64d2dc | 20 | |
Simon_mbed | 2:6a9131b3df01 | 21 | |
no2chem | 0:b5d3bd64d2dc | 22 | |
no2chem | 0:b5d3bd64d2dc | 23 | //This code by Simon Ford: http://mbed.org/forum/mbed/topic/229/?page=1#comment-1225 |
no2chem | 0:b5d3bd64d2dc | 24 | |
Simon_mbed | 2:6a9131b3df01 | 25 | // int Fin = 12000000; // 12MHz XTAL |
Simon_mbed | 2:6a9131b3df01 | 26 | // pc.printf("PLL Registers:\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 27 | // pc.printf(" - PLL0CFG = 0x%08X\r\n", LPC_SC->PLL0CFG); |
Simon_mbed | 2:6a9131b3df01 | 28 | // pc.printf(" - CLKCFG = 0x%08X\r\n", LPC_SC->CCLKCFG); |
Simon_mbed | 2:6a9131b3df01 | 29 | // |
Simon_mbed | 2:6a9131b3df01 | 30 | // int M = (LPC_SC->PLL0CFG & 0xFFFF) + 1; |
Simon_mbed | 2:6a9131b3df01 | 31 | // int N = (LPC_SC->PLL0CFG >> 16) + 1; |
Simon_mbed | 2:6a9131b3df01 | 32 | // int CCLKDIV = LPC_SC->CCLKCFG + 1; |
Simon_mbed | 2:6a9131b3df01 | 33 | // |
Simon_mbed | 2:6a9131b3df01 | 34 | // pc.printf("Clock Variables:\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 35 | // pc.printf(" - Fin = %d\r\n", Fin); |
Simon_mbed | 2:6a9131b3df01 | 36 | // pc.printf(" - M = %d\r\n", M); |
Simon_mbed | 2:6a9131b3df01 | 37 | // pc.printf(" - N = %d\r\n", N); |
Simon_mbed | 2:6a9131b3df01 | 38 | // pc.printf(" - CCLKDIV = %d\r\n", CCLKDIV); |
Simon_mbed | 2:6a9131b3df01 | 39 | // |
Simon_mbed | 2:6a9131b3df01 | 40 | // int Fcco = (2 * M * 12000000) / N; |
Simon_mbed | 2:6a9131b3df01 | 41 | // int CCLK = Fcco / CCLKDIV; |
no2chem | 0:b5d3bd64d2dc | 42 | |
Simon_mbed | 2:6a9131b3df01 | 43 | // pc.printf("Clock Results:\r\n"); |
Simon_mbed | 2:6a9131b3df01 | 44 | // pc.printf(" - Fcco = %d\r\n", Fcco); |
Simon_mbed | 2:6a9131b3df01 | 45 | // |
Simon_mbed | 2:6a9131b3df01 | 46 | // printf(" - CCLK = %d\r\n", CCLK); |
no2chem | 0:b5d3bd64d2dc | 47 | |
no2chem | 0:b5d3bd64d2dc | 48 | printf("Run CoreMark? (Y/N)\n"); |
no2chem | 0:b5d3bd64d2dc | 49 | char buf[8]; |
no2chem | 0:b5d3bd64d2dc | 50 | scanf("%s", buf); |
no2chem | 0:b5d3bd64d2dc | 51 | if (buf[0] == 'y' || buf[0] == 'Y') |
no2chem | 0:b5d3bd64d2dc | 52 | { |
no2chem | 0:b5d3bd64d2dc | 53 | mainCoreMark(); |
no2chem | 0:b5d3bd64d2dc | 54 | } |
no2chem | 0:b5d3bd64d2dc | 55 | } |