Interfacing MMA7455 SPI to CY8Kit-042

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hello,

   

 

   

I'm at my wit's end with this, but I absolutely cannot for the life of me get this accelerometer to work with this board in any way shape or form. I first tried I2C, but this plain does not work despite the fact that the sensor claims to support I2C. I keep getting NACK's back when sending a start with the correct slave address. 

   

So I'm trying SPI. This *appears* to work. I'll send the master control data to the master control register, however when I attempt to read back the status register from the rx buffer, the rx buffer simply contains the very last data I sent from the tx buffer. To be clear, the break out board does not support 4-wire SPI, only 3-wire (bidirectional) which is how I have it set up. 

   

The sensor's data sheet is: http://parallax.com/sites/default/files/downloads/28526-Freescale-MMA7455L-Device-Documentation.pdf

   

Of particular interest are pages 9 and 18. 

   

I've done everything I can possibly do over the course of 2 weeks to get these two devices to play nicely and they just don't seem to want to whatsoever. I've attached the workspace.

0 Likes
11 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum and in the fascinating and sometimes complicated world of PSoCs!

   

I have several accellerometers and magnetic compasses connected to a PSoC 4 and 5 with I2C, and it did work pretty good. When you still have the project that interfaces to I2C I will have a look at when you upload it here. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob
 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

One common problem with integrated and conditioned sensors is power

   

up delay, as well as command delay. Check datasheet for those gotchas.

   

Usually in the "fine" print notes.

   

 

   

There is a contact at the bottom of this thread you might use if forum

   

cannot solve issue. www.element14.com/community/community/designcenter/psoc4_pioneer_kit/blog/2013/12/01/smarter-

   

life-challenge-smart-bicycle-light-update-5

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Thank you Bob for the help.

   

Here is the minimal workspace for the I2C project. I've commented a few lines indicating what is returned from I2CMasterSendStart.

0 Likes
Anonymous
Not applicable

 I forgot to mention that for my I2C circuit, I am using external 4.7k pull up resistors to the 5VDC source.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Stay tuned, here is dinner-time, will take 2hrs...

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Ha! Short glimpse reveils your first error: slave address is 0x1d. So why do you shift it left?? leave it as it is, the component handles all of that. Place a #define for the slave address, so there are fewer changes needed.

   

Bob (now going into the kitchen)

0 Likes
Anonymous
Not applicable

 Thanks for your time,

   

I did try the 0x1D as well for the slave address and get the same results. First status is 0x02. After another attempt it is 0x04.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

So, some more questions: What board are you using? An own?? a Pioneer kit???

   

Probably a Pioneer since you are using P4_0 and 1 for I2C. These two pins already have got pullup resistors and are dedicated for I2C. Remove the additional pullups or use alternate pins P3_0 and 1

   

 

   

You tell that the error is "Last byte NAKed", but that's not a valid status for SendStart() afaik, please check the result again.

   

When an error occurs at SendStart() you may wait a bit of time (as you did) but you have to stop and re-start the I2C-component

   

You specified 1000kb transfer-rate, datasheet tells no "HS" better use 50 and increase later, when working.

   

After SendStart you should go on, or the bus will "hang"

   

Write a byte WhoamI register (0x0F) with WriteByte()

   

then a SendRestart() to read

   

and then read from device with ReadByte() NAKed (should read 0x00)

   

and finally a SendStop ()

   

 

   

Happy coding

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks Bob,

   

I didn't know about the internal pull up resistors. I will remove them and try everything you said. Concerning the NAK error, on pg. 27 of the SCB documentation it indicates that SCB_I2C_MSTR_ERR_LB_NAK is an error, which is the first one returned.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The pullups on Pioneer 2.2K, your 4.7K will not really effect anything as the

   

1.5K result, PSOC 4 has enough drive to handle both.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Thanks for the suggestions.

   

None of them, however, are working. I tried to stop the I2C component, restart it, send a start again, followed by attempting to read from the Whoami reg, and the program hangs on WriteByte(0x0F). The SendStart calls are still returning 0x02 (NAK).

   

 

   

I removed the external pull up resistors as well as dropped the transfer rate to 50kbps.

   

 

   

I've never had this much trouble interfacing a sensor. I'm throwing my hands up here, this is totally baffling.

0 Likes