External EEPROM memory is often a necessary addition to embedded projects, however, troubleshooting at the hardware level can be frustrating and time consuming. The I2C plugin can remove the doubt about the software being at fault. The ability to run the simulation and see at a glance the data being written to the external EEPROM Makes debugging communications much more straightforward. The I2C EEPROM plugin can simulate a device up to 64k bytes covering a broad range of applications.
When numerical data needs to be quickly read 7-segment and 12-segment are usually a good choice.
This tutorial will show how to:
This part of the code in i2cmain.c contains the high level control:
.
.
.
for(num = 0;num < 255;num++)
{
/* Writes address number to the address Location */
ByteWrite( 0x50, 0, num, num+1 );
/* The following line used to display in BCD */
PORTB=char_to_bcd(RetrieveData( 0x50, 0, ( num - 1 ))); /* Reads back to port B in BCD*/
/* The following line used to display in hex */
/* PORTB=RetrieveData( 0x50, 0, ( num - 1 )); /* Reads back to port B in hexadecimal*/
}.
.
.
The for loop controls the addresses written to and increments the values sent as data. The first output line converts the output to BCD form so the data will display correctly in that format. The second output line does not convert the output so the data will display correctly in hexadecimal.
Once the project has been built enter debug mode by clicking the bug on the tool bar.
Configure your plugins like this:
To change to hex output check the radio button. |
The output from the I2C log popup can be saved to file
Pull-Up Data en Clock.
Both the data and clock lines are pulled high signaling the bus is
not busy.
# Start signal received.
When in the idle state and both the data and clock lines are pulled low
by the master a start signal is sent.
(ChipAddress = 1010000) (CodeAddress = 1010000) (R/W = 0)
Send Acknowledge
The EEPROMs address matches the code sent by the master so an acknowledge
is sent by the EEPROM.
Since R/W = 0 a write is initiated.
Address Byte = 00000000
The first half of the address to be written to is
"00000000". (0x00)
Send Acknowledge
The first byte of the address was received. (The plugin is configured for
two address bytes in this example)
Address Byte = 0000000011110101
This is the complete address: 11110101 (0xF5)
Send Acknowledge
The second address byte was received.
Data Byte = 11110101
The data byte to be written is 11110101. (0xF5)
Send Acknowledge
The data byte was received.
# Stop signal received.
The data signal is pulled high by the
master while it holds the clock signal high signaling a stop to the transmission.
# Start signal received.
Another start signal has been received from the master starting the next
transmission.
The I2C EEPROM plugin offers a simple way to debug I2C communications software with out expensive hardware and hookup time. This project has also shown the way the Bcd plugin can be used to simplify the analysis of output data.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
THE AUTHOR RESERVES THE RIGHT TO REJECT ANY LICENSE (REGISTRATION) REQUEST WITHOUT EXPLAINING THE REASONS WHY SUCH REQUEST HAS BEEN REJECTED. IN CASE YOUR LICENSE (REGISTRATION) REQUEST GETS REJECTED YOU MUST STOP USING THE SourceBoost IDE, C2C-PLUS, C2C++, P2C-plus and BoostC COMPILERS AND REMOVE THE WHOLE SourceBoost IDE INSTALLATION FROM YOUR COMPUTER.