Frame rate in mode 15


Sort of. It’s referenced from startup.cpp, which is meant to be linked with either C or C++.


Added some comments to the code example above. In getTime() function, that’s just a divide operation converted to multiply and two shifts (no fixed point numbers).


Yes. Otherwise you’ll get a major burn, in the form of wondering for four days why your code is not actually firing your SysTick. (hint: it’s using the weak C version that is defined in the startup files)


That’s really annoying.
I’ll never understand why people try to mix C and C++.

Are you sure the compiler won’t generate that on its own?

If not, that’s also incredibly annoying.


It’s only an approximation (699/2^25 vs. 1/48000) so compiler shouldn’t do it. Probably unnecessary optimization here anyway. I don’t know if div is that much slower.


The compiler will sometimes convert a division by a constant into a series of shifts, additions et cetera if the substituted operations provide an equivalent behaviour and the trade-off is deemed suitable by the compiler’s metrics (i.e. the speed increase would be significant enough to outweigh the size cost).

(In fact, it’s apparently a very common defect for compilers to generate incorrect replacement code.)

It’s probably a good idea to check, because if this code doesn’t improve speed significantly then then it’s probably not worth the added maintenence cost.