- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was reading some of the examples and thought I could make some quick progress by running a quick test but I seemed to have failed at step one.
I added an EZI2C Slave module to my project and then copied the following code into my main.c:
/* Slave address of the EZI2C */
#define EZI2C_SLAVE_ADDR (0x08u)
#define BUFFER_SIZE (0x04u)
#define BUFFER_RW_AREA_SIZE (0x02u)/* Denotes the offset inside the EZI2C buffer */
#define SLAVE_ADDR_SIZE (0x01u)/* EZI2C buffer */
uint8 ezi2cBuffer[BUFFER_SIZE];/* I2C buffer with the data read from EZI2C */
uint8 i2cBufferRead[BUFFER_SIZE];/* I2C buffer with the data to be written to EZI2C */
uint8 i2cBufferWrite[SLAVE_ADDR_SIZE + BUFFER_SIZE];int main()
{...
/* Start EZI2C */
EZI2C_Start();
/* Enable global interrupts */
CyGlobalIntEnable;
/* Initialize EZI2C buffer's read only data */
ezi2cBuffer[BUFFER_RW_AREA_SIZE ] = 0xAAu;
ezi2cBuffer[BUFFER_RW_AREA_SIZE + 1u] = 0xBBu;EZI2C_SetBuffer1(BUFFER_SIZE, BUFFER_RW_AREA_SIZE, (void *) ezi2cBuffer);
I thought this would be enough to see the 5LP on the I2C bus and even read the initial data but the 5LP doesn't show up on the bus. I have 2 other devices on the board that do show up and I can read from them so the I2C bus seems to be working.
Is there something that I'm missing here?
Thanks,
George
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are using three independent buffers instead of only one. The first part of the buffer is used for the master to read from and write to, the second part is for the master to only read from. the EZI2C_SetBuffer1() tells where the buffer is and where the point between read and write area lies. There is a status call that shows any activities the master has made.
Next time please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file. It will help (at least me) to find any problems.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Thanks for replying. That code was copied straight out of an example I2C slave project. I've attached the project for you.
At this point I wasn't worried about how the buffer was defined or split between read and write boundaries. I have the board connected to a Raspberry Pi and when I issued a "sudo i2cdetect -y 1" I could see the ADC and FRAM on my board (50, 51, 54) but not the 5LP which was using the default 0x08 address. I thought maybe the built-in code didn't respond to polling so I issued a "sudo i2cget -y 1 0x08" to see if I could read the 5LP buffer and I got an error.
Does there have to be explicit code written before the master can read from the slave buffer? I thought what I had written would be enough to get the initial response and prove that I had a good working starting place.
Thanks,
George
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
... waiting for the complete project...
Btw: Where is the FRam from? Or are you using a CY8CKIT-044 Pioneer kit?
Bob
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob. I have to run to a meeting but I'll give this a try tonight and let you know what happens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just ran your test and when I issue the i2cdetect command on the 5LP I don't see a pulse on the LED pin which I changed to P1[7] and monitored by setting the scope to trigger on an edge. I still see the ADC and FRAM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to your schematic you powered VDDIO0, but not VDDIO1, 2 and 3.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, I see that now, talk about brain dead. But before I added the I2C code I programmed the board and had it run the HSSP code which worked. This is the 1st time using the 5LP so I'm not sure what the VDDIO1-3 rails do and why the part would seem to work even if they're not powered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just looked in the datasheet and found this:
So I guess that explains why my I2C connections on P12[0-1] doesn't work. Time for some soldering of some jumper wires and re-testing!
And I just remembered that I was able to run the code to program using HSSP when I was testing with the Dev Kit. I've never used this board to program another board and looking at my connections it won't work unless I jumper VDDIO0 to VDDIO1-3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I added the jumper wires and confirmed that I'm getting 3.3V on all VDDIO0-3 pins. I still wasn't seeing 0x08 when I issued the i2cdetect command. To confirm that VDDIO3 was in fact powered I removed C9, configured P3[2] as an output, and added a toggle to P3[2] in the main section of code. I can probe P3[2] and confirm that I'm getting a square wave.
So now I'm back to being stuck not knowing why the 5LP isn't responding to a i2cdetect command. I also tried "sudo i2cget -y 1 0x08 0x00 b" and I get a read error so it doesn't appear that the 5LP I2C is responding.
In your code I set the LED pin to P1[7] and I can see that pin toggle with each i2cdetect I detect but why would a read fail since the buffer is set up and why doesn't it appear when the i2cdetect command is run?
- 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
Can I have your actual project? Or can you reduce the project to its barest?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The logic analyzer captures are with the example project you provided. I only changed the LED pin and added the toggle on P3[2] to confirm that VDDIO3 was being powered with my jumper wire addition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check the status byte returned by EZI2C_GetActivity() (the call resets all status bits!) for non-zero to see if the slave gets an error condition.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I check that during a debug session or does debug and I2C not get along?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only sleep modes do not go with debugging. Of course you can debug the code using a miniprog3 or a Kitprog.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I'll try that. I was curious if this was something with the EZI2C component so I replaced the EZI2C with a I2C Slave component and modified the code to this:
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. *//* Place your initialization/startup code here (e.g. MyInst_Start()) */
uint8_t buff[1];
buff[0] = 0;
I2C_1_Start();
I2C_1_SlaveInitReadBuf(buff, 1);
// I2C_1_SetBuffer1(1, 1, buff);
for(;;)
{
//if(I2C_1_GetActivity() & I2C_1_STATUS_WRITE1)
if (I2C_1_SlaveStatus() & I2C_1_SSTAT_WR_CMPLT)
// if(buff[0])
{
Led_Write(!Led_Read());
}
Blinky_Write(!Blinky_Read());
CyDelay(100);
}
}
I got the same results so I wasn't lucky. I'm still curious though why i2cdetect works with other I2C parts but it doesn't appear to work with Cypress' component. I can't imagine I'm the first to have tried this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just red that the Raspi GPIO pins are using 3.3V, can it be that your PSoC board runs at 5V?
There is a level shifter to allow the PSoC board's I2C at 3.3 or 5V which includes the pull up resistors. You may not use these pins, because the Raspi has its own pullups.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank for continuing to think about this. No, the 5LP is running at 3.3V, it gets that from the LSO output of the TPS2149. The other 2 devices on this board are responding to i2cdetect and i2cget so this should prove that the I2C bus is in a good state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To eliminate the possibility of my board causing some issue I took a new 5LP kit and programmed it with your example code. I used the Raspberry Pi's 3.3V output to power the 5LP and connected the I2C signals to P12[0:1]. The LED on the 5LP board toggles with each i2cdetect command but the 5LP is not detected.