Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Debugging of FX2LP Firmware using I2C - KBA229175

lock attach
Attachments are accessible only for community members.

Debugging of FX2LP Firmware using I2C - KBA229175

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Author: SananyaM_56           Version: **

Translation - Japanese: I2Cを使用したFX2LPファームウェアのデバッグ - KBA229175 - Community Translated (JA)

Question:
How can I use the I2C interface in FX2LP to send debug messages?

Answer:

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.

Requirements 

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.

pastedImage_15.png

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.

pastedImage_21.png

3. Go to the SCB 0 tab, and set the Mode as I2C. Click Configure.

pastedImage_27.png

4. Configure SCB 0 as I2C Slave with the required slave address, and click OK.

pastedImage_33.png

5. Set the protocol as VCP and click Program.

pastedImage_44.png

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.

Debug Files  

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.

  • FX2LP_I2C.h - The FX2LP_I2C.h header file contains the function definitions for all functions in FX2LP_I2C.c. This header file must be included in the project to access the functions in FX2LP_I2C.c.
  • FX2LP_I2C.c - The FX2LP_I2C.c file includes all required functions for I2C debug.

Test Setup

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

pastedImage_67.png

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

pastedImage_82.png

5. Open the bulkloop.c file and add the FX2LP_I2C.h header file reference.

Figure 3. Adding Header File Reference

pastedImage_92.png

6. Compile once and make sure that the files FX2LP_I2C.c and FX2LP_I2C.h are included in the project.

Modifying Firmware

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.

  • TD_Init () – The following code snippet initializes the I2C bus and prints a string to reflect the same. Then, prints the value of IFCONFIG.

   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("\r\n");

  • TD_Poll () – The following code snippet prints a string to indicate the transfer of a packet from EP2 to EP6 and the byte count of the packet.

   FX2LPI2C_XmitChar('P');

   FX2LPI2C_XmitString("acket of Byte Count = ");

   FX2LPI2C_XmitHex4(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.

pastedImage_98.png

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.

pastedImage_108.png

Figure 10. Setting the I2C frequency as baud rate

Testing

The USB control center uses USB to download the compiled .hex file. Follow these steps to test the example firmware:

1. Plug the CY3684 EZ-USB FX2LP DVKboard into the computer using a USB cable and bind it to the driver cyusb3.sys. Download and install EZ-USB FX3 SDKto launch USB Control Center.

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.

pastedImage_120.png

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.

pastedImage_129.png

pastedImage_134.png

As FX2LP executes the code, debug messages are printed to the Tera Term.

pastedImage_139.png

Attachments
0 Likes
2024 Views
Contributors