cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Accelerometer Configuration

vault
Associate
Posted on May 08, 2013 at 17:40

Hi,

I'm trying to configure the accelerometer on my stm32f4 discovery board. I lost with all the configuration of LIS302DL and TIM4 (example code) and do I need to configure SPI1 separately??? I simply want to read the Z axe measurements for tilt calculation. with this configuration:

1.
/* Set configuration of LIS302DL*/
2.
LIS302DL_InitStruct.Power_Mode = LIS302DL_LOWPOWERMODE_ACTIVE;
3.
LIS302DL_InitStruct.Output_DataRate = LIS302DL_DATARATE_100;
4.
LIS302DL_InitStruct.Axes_Enable = LIS302DL_Z_ENABLE;
5.
LIS302DL_InitStruct.Full_Scale = LIS302DL_FULLSCALE_2_3;
6.
LIS302DL_InitStruct.Self_Test = LIS302DL_SELFTEST_NORMAL;
7.
LIS302DL_Init(&LIS302DL_InitStruct);

How I configure it? #accelerometer #lis302dl
2 REPLIES 2
raptorhal2
Lead
Posted on May 11, 2013 at 15:25

#@*&%^$ forum died last night and ate my response.

It is a formidable task, but ST has done most of the work for you. Towards the end of the .zip file in the Utilities group is an LIS302DL driver and associated header files. The driver performs the SPI and GPIO initialization for the accelerometer related pins required to communicate with the accelerometer. You will need to write a main.c to perform writes and reads on the accelerometer to initialize it and read the acceleration data. Based on what you seem to want to do, timer code is not required.

If the Z axis is initially pointing down, better sensitivity at small tilt angles can be achieved by using a vector sum of the x and x (correction: y) axis data, but I digress.

Cheers, Hal

shreyavsanoj7
Associate

which header file did u use? Im a beginner so idk much