- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone: I am working on a project in which I want to use two accelerometers on a PSOC4 BLE. I worked with an example where an I2C is connected a single accelerometer. I want to add another accelerometer. Could anyone point to me a PSOC example that could help me understand how to connect multiple sensors on an I2C. I read about I2C bus and about master/slave concept, but did not understand a lot.
It would be great if you could also answer following question:
1. when should I use master I2C and when a slave I2C?
2. is it possible to have two I2C each with one accelerometer connected to four pins on PSOC? right now I have one I2C with SCL going in pin 3[5] and SDA going in pin 3[4].
Thanks you in advance:
Apoorva
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and name them slave? Not name but configure as master. And usually, as hli pointed out, you will need only one I2C component for both slaves. Do not assign pins to the sda and scl lines and build the project, the fitter will assign the correct pins.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As long as your accelerometer supports assigning different addresses to different devices (usually by pin configuration), you can do this. If not, you need two different I2C ports (which works when your device has two I2C modules)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. when should I use master I2C and when a slave I2C?
Usually a sensor is an I2C slave, so the PSoC will act as master.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for replying Hli and Bob. Do you know if there is such an example in PSOC?
@Hli: how do I know that a board has multiple I2C ports such as CYBLE-022001. I searched but failed because i lack the right knowledge. and how do do i know which pins can be assigned to I2C?
@Bob: I would like to use PSOC as master and two accelerometers as slave. Now, do i drop multiple I2C icons on psoc creator workspace and name them slave?
thank you again. apoorva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and name them slave? Not name but configure as master. And usually, as hli pointed out, you will need only one I2C component for both slaves. Do not assign pins to the sda and scl lines and build the project, the fitter will assign the correct pins.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at the data sheet for your device, it should state that. Or just place a second I2C component and try to compile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much Hli and Bob for your prompt reply. I now try what you suggested.
- 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
In Creator on the very right side is a tab named "Resource meter". This shows that you are trying to use 3 of only 2 available SCBs.
There is no need for 2 I2C masters, you can address up to ~100 slaves. The MPU6050 allows for setting the slave address, so you can address each module individually.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Bob, thats very helpful. Could you also point me to an example where an I2C is used for addressing 2 or more slaves. I went through a PSOC document on I2C bus, and I hope I will understand better if I see an example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is too easy for creating an eyample:
The API I2C_MasterWriteBuf(SlaveAddress,DataPtr,Count,I2C_MODE_COMPLETE_XFER); (see I2C datasheet) contains the slave address (which is a value between 1 and 126). Look into the sensor's datasheet for the basic 7-bit address.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is too easy for creating an example:
The API I2C_MasterWriteBuf(SlaveAddress,DataPtr,Count,I2C_MODE_COMPLETE_XFER); (see I2C datasheet) contains the slave address (which is a value between 1 and 126). Look into the sensor's datasheet for the basic 7-bit address.
Bob