??? 05/30/07 12:56 Read: times |
#140060 - i2c function signatures Responding to: ???'s previous message |
Philippe Latu said:
At first sight, I thought it was a good idea to split function calls to highlight acknowledge with the two functions sendack and getack. Reading Jan's posts and yours, it seems this is not a good practise. As I'm writing this code for teaching purposes, I have to respect the "good practises". Should I "reintegrate" these acknowledge transactions into getbyte and putbyte in order to retrun proper error codes ? I would suggest: void i2c_init(void); // float SCL and SDA lines etc. bit i2c_start(void); // return TRUE if bus is free bit i2c_putbyte(uint8 ch); // return TRUE for ACK uint8 i2c_getbyte(bit more); // more sets ACK or NAK after reading single byte void i2c_stop(void); // initiate page-write, release bus I personally use uint8 returns rather than bit returns. (So that I can return hardware status from i2c chip hardware) I personally do not like using state machines for coding a software i2c master. In practice the polling is very necessary when addressing a slave device. Once the device is listening you can perform multiple reads or page-writes fairly seamlessly. Implementing a slave device in software generally requires using interrupts and state machines. Hardware support is very preferable. I misread your original posting. A 24C02 has an 8 byte page buffer. Good luck with your students !! David |
Topic | Author | Date |
I2C eeprom 24c02 byte write stuck in ack | 01/01/70 00:00 | |
timing | 01/01/70 00:00 | |
timing | 01/01/70 00:00 | |
what\'s the problem, exactly? | 01/01/70 00:00 | |
timing | 01/01/70 00:00 | |
how do you know that? | 01/01/70 00:00 | |
How do you know that? | 01/01/70 00:00 | |
do you have some other version of code? | 01/01/70 00:00 | |
do you have some other version of code? | 01/01/70 00:00 | |
A work around For That | 01/01/70 00:00 | |
work around For That | 01/01/70 00:00 | |
Well in my guess, you have same problem:-) as mine | 01/01/70 00:00 | |
Polling the 24C02 EEPROM for ready | 01/01/70 00:00 | |
OOPS wrong logic | 01/01/70 00:00 | |
I thought that I should try your code | 01/01/70 00:00 | |
Polling the 24C02 EEPROM for ready | 01/01/70 00:00 | |
great, but do not forget to mention | 01/01/70 00:00 | |
The Clock | 01/01/70 00:00 | |
addition - show the full picture - 'edit' to above![]() | 01/01/70 00:00 | |
i2c function signatures | 01/01/70 00:00 | |
hello friend | 01/01/70 00:00 |