EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: ebclr on January 11, 2017, 09:51:46 am
-
I use mbed sinewave example and evaluate the results on generating analog sinewave on 4 diferent nucleo boards just for fun no optimization , only play mbed example
Results
F767 15.8 Khz
F429 5.98 Khz
F072RB 704 Hz
L152 638Hz
#include "mbed.h"
AnalogOut my_output(PA_4);
#define PI (3.141592653589793238462)
#define AMPLITUDE (1.0) // x * 3.3V
#define PHASE (PI * 1) // 2*pi is one period
#define RANGE (0x7FFF)
#define OFFSET (0x7FFF)
// Configuration for sinewave output
#define BUFFER_SIZE (360)
uint16_t buffer[BUFFER_SIZE];
void calculate_sinewave(void);
int main() {
printf("Sinewave example\n");
calculate_sinewave();
while(1) {
// sinewave output
for (int i = 0; i < BUFFER_SIZE; i++) {
my_output.write_u16(buffer);
// wait_us(10);
}
}
}
// Create the sinewave buffer
void calculate_sinewave(void){
for (int i = 0; i < BUFFER_SIZE; i++) {
double rads = (PI * i)/180.0; // Convert degree in radian
buffer = (uint16_t)(AMPLITUDE * (RANGE * (cos(rads + PHASE))) + OFFSET);
}
}
-
No optimization compilation usually produces awful code - it is useful just for debugging, where you need to step through code and not being disturbed by optimizer shuffling your code all over the shop or "hiding" variables. At least O1 optimization produces much better code density.
Along with "benchmark results" you should also provide CPU clock speed.
Benchmarks are somehow black magic, with lot of folks having very different opinions and discussing forever; some benchmarks are specific to particular action (floating point, random or sequential memory access) do work better on some architectures and perform poorly on another.
-
What CPU clock frequency was each board running at?
-
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f767zi.html (http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f767zi.html)
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f429zi.html (http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f429zi.html)
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f072rb.html (http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f072rb.html)
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-l152re.html (http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-l152re.html)
-
Easier to get the data from here I think https://developer.mbed.org/platforms/?pvend=10
I'm not sure exactly what the benchmark is testing (DAC output and simple loop?), but interesting to see the M3 at 32MHz is not much faster than M0 at 48Mhz. M4 is roughly 6x faster than M3, and M7 2x faster than M4.
It's obviously not just clock speed that is the factor, there are also differences in instruction sets, caching and bus architecture. It could be that all of the difference is down to caching, so probably a pretty useless benchmark.