Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
If BCM2073x connects a powerful host MCU and the host MCU has a big capacity memory, it’s possible to store the BCM2073x image in the host MCU memory. But the host MCU usually does not have I2C slave port, so we implement the code to emulate I2C slave timing of EEPROM by using two GPIOs on host MCU side. This document introduces how to port the emulation code for different MCU.
The code only emulates reading data from EEPROM, because it’s difficulty to catch the I2C slave timing when writing data to EEPROM.
Detect the SCL/SDA level by polling in emulation code. Please disable the interrupt when running the simulation code, because one or more I2C SDA/SCL bit will be missed when executing the ISR. The valid level of SCL/SDA only keeps 5us when I2C speed is 100K, and only keeps 1.25us when I2C speed is 400K.
The emulation code needs fine-tune after porting based on different HW.
I2C Timing of EEPROM
The following figures are the timing of read or write EEPROM, please refer to EEPROM datasheet to get more information.
1. Random Read
2. Sequential Read
3. Byte Write
4. Page Write
State Machines of Emulation Code
The emulation code runs on host MCU side only for reading the BCM2073x image from the host MCU memory. BCM2073x loads the image from EEPROM by “Random Read” or “Sequential Read”.
The following is the state machines of emulation code.
SM1 - Idle
SM2 - Receive device address from BCM2073x
SM3 - Receive the data address from BCM2073x
SM4 - Send data to BCM2073x
SM1 - Idle
Detect I2C start bit, transfer to SM2 if found the I2C start bit, or exit the simulation if not detect the start bit after idle timer timeout expires.
SM2 – Receive device address from BCM2073x
Receive the device address, transfer to SM1 if device address isn’t matched, or transfer to SM3 if the device address is matched.
SM3 – Receive data address from BCM2073x
Receive the two byte data address, transfer to SM4 if the correct address is gotten.
SM4 – Send data to BCM2073x
Send one byte data to BCM2073x, transfer to SM1 if got the I2C stop bit, or keep the SM4 and continue to send more data if ACK is received.
1. Re-write the following functions.
2. Re-define the follow timeout.
#define SCL_HIGH_TIMEOUT 200
#define SCL_LOW_TIMEOUT 200
#define STOP_TIMEOUT 1000
#define START_TIMEOUT 1000
#define IDLE_TIMEOUT 5000 // 2s
3. Change the WICED SmartCode to make the corresponding BCM2073x image.
Enable the RAMBUFENABLE macro in sparinit.c, use the RAM to store the data that wrote to NVRAM (VS section in EEPROM).
Change the I2C speed from 400K to 100K in the mandatory.cgs if can’t catch the I2C 400K timing.
Don’t use functions that like “printf” to debug code, because the SCL/SDA bit will be missed when executing these functions.
Suggest using the following ways to debug code.
Use another two GPIOs to sync the SCL/SDA timing in the I2C communication, named the two GPIO as following SCL/SDA. We can look the waveform of following SCL/SDA to judge whether code is correct or not. If the waveform of following SCL/SDA matches the waveform of original SCL/SDA, it means the emulation works correctly.
Save the running information in the temporary variants when running the emulation code, and print the variants when exited the emulation.
Generate the BCM2073x Image Array
If the host MCU has file system, you can directly store the BCM20732 binary image (*.bin) in the file system. If the host MCU does not have the file system, we usually use an array to store the BCM20732 image in MCU memory. Refer to the following steps to generate the BCM2073x image array.
Run windows console on PC.
Covert image from HEX format to BIN format.
ihex2bin.exe -f 0x00 xxx.hex xxx.bin
3. Covert BIN image to an array.
bin2c -m 128 xxx.bin xxx.h xxx_image
4. You can find the image array named xxx_image in xxx.h.