This project demonstrates I2C communication between PsoC4 and FM4. Here PsoC4 acts as I2C Master and FM4 acts as I2C Slave. PSoC4 sends Capsense data to control the brightness of LED on FM4 kit.
OverviewCapsense component in PsoC is used to get the slider position on PsoC4 kit. This slider position is copied to the I2C master command buffer and send to the I2C slave.
MFS (Multi-Function Serial Interface) on FM4 is configured to work as I2C slave. BT (Base Timer) in FM4 is used as a PWM to control the brightness of LED on the kit. The command received by I2C slave is used to adjust the PWM duty cycle and hence control the brightness of on board LED.
Requirements- Design Tool: PSoC Creator 3.3 SP2 or above, IAR Embedded Workbench for ARM, PDL 2.1.0
- Programming Language: C (ARM GCC 4.9-2015-q1-update – included with PSoC Creator), C for IAR
- Associated Devices: MB9BF56xR, PSoC 4
- Required Hardware: FM4-U120-9B560 - ARM® Cortex®-M4 MCU Starter Kit, CY8CKIT – 042BLE
Connect the I2C lines on PsoC4BLe kit and FM4-U120-9B560 kit. Use 2.2K pull up resistors on the I2C lines. Here are the I2C pins used on both the kits.
- SCL: PsoC Kit- P3.5 FM4 Kit- SOT7_1 (Pin# P4D)
- SDA: PsoC Kit- P 3.4 FM4 Kit- SCK7_1 (Pin#P4C)
Make sure both the kits are powered at 5V and GNDs are connected together.
Project DetailsThe PSoC4 BLE project has Capsense component configured for a linear slider. There is one I2C master component and two Leds to indicate the I2c communication status. Top schematic of PsoC project is given below.
FM4 project has been created in IAR embedded Workbench. MFS and BT components are enabled in PDL. MFS is configured for I2C slave, with 0x08 as address and 100Kbps data rate.
The IAR project workspace attached here has these sub folders - drivers, mb9bf56xr
and cmsis
mb9bf56xr /Projects
You need to set the directory paths for these folders under “Preprocessor” in the Project Build Settings. Also add mfs.c
bt.c
pdl.c
and pdl_user.h
files to the Workspace.
Testing the Project
- 1. Make the connections between PsoC4 BLE kit and FM4 kit.
- 2. Program the I2C Master project to PsoC4 and I2C slave project to FM4. You need to use CN3 on the FM4 kit. Use '
download and debug
' option in IAR.
- 3. Move your finger over the Capsense slider on PsoC4 kit. You will see the brightness of Red LED on FM4 kit varies. Also, the green LED on the PsoC4 kit glows indicating the I2C communication is successful.
Comments
Please log in or sign up to comment.