Hello, did someone write some baremetal code for reading the mma8451 accelerometer data and also calculate the angles. Is there a tutorial anywhere?
The FRDM-KL25ZDemo, which can be found in the KL25z sample code, contains baremetal code for angle calculation which can be found in the "angle_calculation" directory in the project folder. The KL25z sample code can be found here FRDM-KL25Z: Freescale Freedom Development Platform for Kinetis KL14/15/24/25 MCUs under Downloads >> Software Development Tools >> Lab and Test software. Hope this helps.
Hi, thanks for the answer. I looked at this already but its hard to understand why he do so. Maybe a closer look will help i try my best.
You can give a look to the step by step tutorial in the next link. It does not mention the angle calculation, but you can develop your own algorithm with the basics explained:
Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse
Hope this helps!
You might also find useful my baremetal example code for the MMA8451Q accelerometer and FRDM-KL25Z platform. I will try to add a few lines of code to calculate an angle of inclination using atan2 function and then I will post it here.
Attached you can find the complete example code that computes both pitch and roll angles according to equations 37 and 38 in the AN3461.
I hope it helps.
Just in case you wanted a convenient breakout board to interface and probe the data here is one: Accelerometer(MMA8451) 3-AXIS Digital Module - DoProto Electronics
Retrieving data ...