- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. i call the function I2C_M_Start();
2. write a data buf to eeprom:
I2C_M_MasterWriteBuf(SLAVE_ADDR, buf, num, I2C_M_MODE_COMPLETE_XFER);
/* Wait till write operation is complete*/
while (!(I2C_M_MasterStatus() & I2C_M_MSTAT_WR_CMPLT))
{
;
}
//the buf includes the address of eeprom memory.
3. write another data buf to eeprom:
I2C_M_MasterWriteBuf(SLAVE_ADDR, anotherbuf, num1, I2C_M_MODE_COMPLETE_XFER);
/* Wait till write operation is complete*/
while (!(I2C_M_MasterStatus() & I2C_M_MSTAT_WR_CMPLT))
{
;
}
4. i call the function I2C_M_Stopt();
my question :
2 worked 3 did not work
when i commented 2, the 3 woked.
maybe i was wrong about the mode(now is I2C_M_MODE_COMPLETE_XFER).
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should at least check the returned value of the MasterWriteBuf() to see if it completed without an error.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your EEPROM needs additional time to finish its write. I2C_M_MasterStatus() only waits for the I2C-transfer to be finished - but writing the EEPROM will take more time. And when you try to write too soon, you will get an error.
E.g. see the data sheet for a 24LC1025 (http://ww1.microchip.com/downloads/en/DeviceDoc/21941K.pdf ) page 11 for an example. What device are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Onchip EEPROM takes worst case 20 mS to write a row/block,
and is a blocking function when called, so I2C after fill of buffer
to be written, has to be stopped from further buffer activity until
buffer is completely written to EEPROM.
If you right click EEPROM, find example project, there is one you can
add to your design or open in a new deisgn window.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my eeprom device is M24256.
i added CyDelay(50) between 2 and 3.
the 3 worked.
thank you all very much.
谢谢!!!(my english is poor .)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i find the content above in the datasheet.
so i can change CyDelay(50) to CyDelay(10).
am i right ? i will test next.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should poll the EEPROM to find out whether it has finished writing or not. See page 18 in the data sheet (http://www.st.com/web/en/resource/technical/document/datasheet/CD00001891.pdf )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
oh, i see two ways:
1. polling the EEPROM to make sure that the sencod buf can be written.
2. just Call CyDelay(ms>MAX).
the first must be right , the second now i use maybe right.
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
oh, i see two ways:
1. polling the EEPROM to make sure that the sencod buf can be written.
2. just Call CyDelay(ms>MAX).
the first must be right , the second now i use maybe right.
thanks.