Author: SananyaM_56 Version: **
Translation - Japanese: I2Cを使用したFX2LPファームウェアのデバッグ - KBA229175 - Community Translated (JA)
How can I use the I2C interface in FX2LP to send debug messages?
The FX2LP I2C controller acts as a master and can be connected to an I2C slave for sending debug messages. This is useful when any code needs to be debugged in real time, especially with the 56-pin package which does not have a UART interface. This knowledge base article (KBA) discusses the steps to configure and receive debug messages from FX2LP over an I2C interface.
The USB-Serial CYUSBS236 kit can act as the I2C slave in the Virtual COM Port (VCP) mode. This mode will allow the device to enumerate as a COM port on the host and bind to Cypress CDC (Communications Device Class) driver. This interface can be used to view the messages received on the I2C interface on a Serial terminal such as Tera Term.
Use the USB-Serial Configuration Utility and follow these steps to configure the device:
1. In the Cypress USB-Serial Configuration Utility, go to the Select Target tab. Select the device from the drop-down list, and click Connect.
2. Go to the SCB 1 tab, and disable SCB 1 on CY7C65215 to ensure the device enumerates properly when SCB 0 is configured for I2C operation.
3. Go to the SCB 0 tab, and set the Mode as I2C. Click Configure.
4. Configure SCB 0 as I2C Slave with the required slave address, and click OK.
5. Set the protocol as VCP and click Program.
6. Reset the device and check the device manager to see if the device enumerates properly.
7. Connect SCL and SDA lines of the USB-Serial device to Pin 10 (SDA) and Pin 11(SCL) on FX2LP Make sure the I2C lines connected to FX2LP have pull up resistors present on them.
The files attached with this KBA include functions to send messages in byte, word, character, or string format and can be included with any FX2LP project.
The Bulkloop example firmware is used to demonstrate the debugging procedure. This example firmware is available at C:\Cypress\USB\CY3684_EZ-USB_FX2LP_DVK\1.0\Firmware\Bulkloop after installing the CY3684 EZ-USB FX2LP Development Kit. Modify the example code to include the debug files attached with this KBA.
Adding Files to the Target Code
Follow these steps to add the debug files to the target Keil project:
1. From the left pane of the project window, right-click Target 1.
2. From the pop-up menu, click Options for Target ‘Target 1’.
Figure 1. Selecting Options for Target ‘Target 1’ in Project Menu
3. In the Options for Target ‘Target 1’ window, go to the C51 tab.
4. In the Include Paths textbox, enter the path to the FX2LP_I2C.h header file. Click OK.
Figure 2. Specifying Include Path
5. Open the bulkloop.c file and add the FX2LP_I2C.h header file reference.
Figure 3. Adding Header File Reference
6. Compile once and make sure that the files FX2LP_I2C.c and FX2LP_I2C.h are included in the project.
Modify the bulkloop.c example project to use the I2C debug functions as shown in the following example.
The FX2LPI2C_Init() function is called within the TD_Init () function in bulkloop.c. This ensures that the I2C bus is initialized and ready for use at any point during code execution. The other required functions are called wherever necessary as described in the following sections.
Note that the I2C slave address has been set as “0x02” to match the USB-Serial slave address and it can be modified in the FX2LP_I2C.h debug file.
FX2LPI2C_Init();// I2C Debug Code Start
FX2LPI2C_XmitString("Debug mode initialized\r\n");
// set the slave FIFO interface to 48MHz
IFCONFIG |= 0x40;
FX2LPI2C_XmitHex2(IFCONFIG); //Printing the value of IFCONFIG
FX2LPI2C_XmitString("acket of Byte Count = ");
FX2LPI2C_XmitString(" being moved to EP6\r\n");
Tera Term Settings
Set Tera Term such that it prints debug messages received through the I2C interface on the USB-Serial device.
1. Open Tera Term. Select the appropriate COM port (that the USB-Serial device enumerates with) in the New Connection window and click OK.
Figure 9. Selecting the COM port
2. Go to Setup > Serial Port. The debug files use 100 kHz as the I2C frequency from FX2LP. So, enter the I2C frequency, 10000, as the Baud rate. Click OK. Note that 400 kHz can also be used, but the FX2LP_I2C.h debug file should be modified accordingly.
Figure 10. Setting the I2C frequency as baud rate
The USB control center uses USB to download the compiled .hex file. Follow these steps to test the example firmware:
2. Go to C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\c_sharp\controlcenter\bin\Release and run CyControl.exe. The USB Control Center window appears.
3. Follow the menu path Program > FX2 > RAM. In the pop-up window that appears, navigate to and select bulkloop.hex, which includes the debug messages and should be present in the Bulkloop folder.
As FX2LP executes the code, debug messages are printed to the Tera Term.