Hello,
I'm trying to use the MMA8451Q accelerometer with I2C communication. I don't want to use process expert. I've studied closely the I2C module for kinetics family from the kl25z manuel and the MMA8451Q from the Data Sheet http://www.newark.com/pdfs/techarticles/freescale/MMA8451Q.pdf
I've studied the code generated from process expert, but it uses interruption so it is a little bit different, making the comparison between the programs harder.
My code is attached, it is small, simple and I commented it to help the comprehension. I'm will be really glad to answer any doubts about it. When I run it, my read function only returns 0xff or 0x00 from the I2C0_D, no matter what.
Does anyone has harcoded this before or know what can be wrong with it? I would appreciate any help on that.
Regards,
Original Attachment has been moved to: main.rar
humbertoaboud Hello, please send me a reference or the project itself. It is important to work without mistakes and failures.
please upload the code related to i2c,its needed to my project
I used this example and it works great.
Thanks a lot for the help juanm,
This example you sent me made me figure out that I was using the wrong address of the control register one of the MMA8451, as I wrote in reply to Erich. It was still not working though, then I figured out that my I2C read register function used to change to the receiver mode before waiting for the conclusion of the transmission.
Fixing those two things did the job, and it works perfectly now.
I will post my code here later so if someday someone wants to do it by coding it can be used it as reference, thanks!
HI CAN U SEND ME THE CODE
Hi, I would greatly appreciate it if you could post your updated code. I'm having trouble using the I2C communication, and I also don't want to use Processor Expert. Thanks!
Hi Lily
http://www.utasker.com/kinetis/FRDM-KL25Z.html
http://www.utasker.com/docs/uTasker/uTaskerIIC.PDF
All code available. Doesn't need PE. Automatic I2C deal-lock recovery built in. Kinetis, I2C and project can be simulated in VisualStudio.
Regards
Mark
Kinetis: µTasker Kinetis support
KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support
For the complete "out-of-the-box" Kinetis experience and faster time to market
Hello,
first I want to mention that the Processor Expert I2C driver can be with or without interrupts: using interrupts is just the normal case (at least for me).
Have you seen the Freescale provided example code on:
FRDM-KL25Z: Freescale Freedom Development Platform for Kinetis KL14/15/24/25 MCUs
?
I recommend that you use a logic analyzer to check the signals on the bus, as many things could be wrong. You even could use a FRDM-KL25Z as logic analyzer (see Tutorial: Using the FRDM-KL25Z as Low Power Board | MCU on Eclipse). Make sure that you verify your internal clock distribution settings, as there is an errata on this (see KL25Z and I2C: Missing Repeated Start Condition | MCU on Eclipse).
I hope this helps,
Erich
Thanks a lot for the help Erich,
I don't want to use process expert, with or without interrupts, I'm trying to code everything by myself. Fortunately, I fixed my code today, it had two problems:
I will post my code here later so if someday someone wants to do it by coding it can be used it as reference.
HI CAN U SEND ME THE CODE