- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I forgot to mention that for my I2C circuit, I am using external 4.7k pull up resistors to the 5VDC source.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Stay tuned, here is dinner-time, will take 2hrs...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.