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.
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
I forgot to mention that for my I2C circuit, I am using external 4.7k pull up resistors to the 5VDC source.
Stay tuned, here is dinner-time, will take 2hrs...
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)
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.
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 ()
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.
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.
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.