cancel
Showing results for 
Search instead for 
Did you mean: 

I2C code need

raj2
Associate II
Posted on March 28, 2013 at 13:40

hello ,

i am using stm32f3 discovery kit which has inbulit accelerometer sensor.

i need a code to read the accelerometer data.

please help .

#rtfm
6 REPLIES 6
Andrew Neil
Evangelist III
Posted on March 28, 2013 at 14:03

So why don't you look at the examples provided for the Discovery board?

Or the examples included in the Standard Peripheral Library?

http://www.keil.com/forum/22429/

raj2
Associate II
Posted on March 28, 2013 at 18:14

yes i check all example but not able to find any example related to I2C prtocol using to capture  accelerometer data.

 

sdim2
Associate II
Posted on March 31, 2013 at 15:43

Download the firmware examples

http://www.st.com/web/en/catalog/tools/PF258154

Unpack the file and go to the folder

STM32F3-Discovery_FW_V1.1.0\Project\Demonstration\

Open the correct project with your IDE. It is the demo firmware that ships with the board, it has all the code you need.

raj2
Associate II
Posted on April 02, 2013 at 13:03

hello sdim

i run the demonstration code(stm32f3 discovery kit ) its working when i  used to open that original   project but when i copy  that main file code(main.c) in to some other project  it hang at some infinite loop . 

i added all liberary and added all valod path .

sdim
Associate III
Posted on April 03, 2013 at 20:07

If you use the demonstration project file on another project, first verify that both projects use the same libraries. Different versions of ST standard peripheral libraries and CMSIS libraries have some changes that may be the source of your problem.

The next step is to open side by side two instances of your IDE, one with your project and one with the demonstration project. Then open the project configurations options and verify that the options are the same or compatible.

The best option for me is to avoid importing another file to my projects. When I find another project that has some functionality I want, I just go through its'  code until I understand how it works (right click->go to definition really helps). Then I implement the same functionality on my project from ground up.

Posted on April 03, 2013 at 20:49

Sounds like you need to learn how to use your IDE, and create projects properly.

May be you can clone a working project, but you should consider all the metadata stored in the options, be it compiler settings, defines, FPU enabled, etc.

If your code ends up in an infinite loop, probably a Hard Fault, you really need to learn how to debug things. Are you using FPU instructions, is the FPU enabled, is that faulting.

Is it stuck in one of the I2C waiting loops. These are obviously poorly constructed, but still you could figure out which one it's stuck in.

Learn how to use your tools, or you'll be wasting hours fighting these problems.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..