cancel
Showing results for 
Search instead for 
Did you mean: 

MEMS-Sensors with STM32F4 Discovery

Posted on June 13, 2017 at 22:19

Hello everybody, 

I am a student and I really don't have a clue how to program an uController. This year we have a big project with a STM32F4 Discovery board. We need to read the data from an additional board, that includes 3 Sensors: Accelerometer, Gyroscope and Magnetometer

. We are not allowed to use the CubeMx or any additional Libraries, but we do have a starting program to help us.

Can you please give me some 'to do list', some plan how to start, what i need to do?

For example, this is the main:

//

// Main.cpp

//

&sharpinclude <Compiler.h>

&sharpinclude <Cortex-M.h>

&sharpinclude <Debug.h>

&sharpinclude 'STM32F4xx_Init.h'

&sharpinclude <STK.h>

static bool volatile runMainLoop = true;

/// Program entry.

DECL_NO_RETURN int main(void)

{

ITM_PUTS('It all starts here!');

ITM_PRINTF('AHB clock = %u Hz', HClk());

ITM_PRINTF('APB1 clock = %u Hz', PClk1());

ITM_PRINTF('APB2 clock = %u Hz', PClk2());

STM32F4xx_Init();

ITM_PUTS('Controller has been initialized');

/// User initialization may start here

/// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/// End of user initialization!

/// Das BASEPRI-Register ist im Start-up-Code auf 0x10 eingestellt worden. Damit kann kein IRQ mit niedrigerer oder gleicher Prio

/// aktiv werden. Erst mit dem Auruf der nachfolgenden Funktion k�nnen alle IRQs aktiv werden.

SetBASEPRI(0U);

ITM_PRINTF('BASEPRI=0x%08X', GetBASEPRI());

/// Indem Bit &sharp0 im CONTROL-Register des Cortex-M4 gesetzt wird, wird der Prozessor in den non-priviliegierten Modus gesetzt.

/// Damit k�nnen diverse, wichtige Einstellungen nicht mehr versehentlich �berschrieben werden.

/// Aber Achtung: Der Exception-Modus ist immer privilegiert, unabh�ngig von CONTROL[0].

SetCONTROL(1U | GetCONTROL());

ITM_PRINTF('CONTROL=0x%08X', GetCONTROL());

ITM_PUTS('Starting main loop');

while ( runMainLoop )

{

}

ITM_PUTS('This is the end!');

ResetController();

}

Thank you in advance!

#accelerometer #mems #sensors #magnetometer #gyroscope #example #code
1 REPLY 1
AvaTar
Lead
Posted on October 20, 2017 at 12:30

You did not specify the INS module you are dealing with, but there are surely code examples for the F4 discovery, usually based on the SPL.

While you might be not allowed to use the libs directly, you can investigate the sources, and re-use it's methods - including code sequences.