Hello!
This Project demonstrates the simultaneous use of UART, SPI and I2C protocols of communication in one single project. SPI is used to communicate the position of the Joystick in the Pmod JSTK Joystick Module. The I2C is used to obtain the current time from the Real Time Clock (RTC). UART is used to print the time obtained via I2C on the Hyperterminal and move its position in accordance with the Joystick.
- PSoC 4 Pioneer Kit
- PmodJSTK – 2 Axis joystick
- Real Time Clock DS1307
Forum Post Attachments:
At the bottom of this post we are including the following items:
- Example Project Zip File
- Zip File of Images
- Project Schematic
- Component Configurations
Components Used:
The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:
- SPI
- I2C
- UART
- CyPins
- CyClock
The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.
Firmware Description:
The main.c firmware is included in the example project. Please review the commented sections for more details.
This firmware example is an excellent demonstration of how the PSoC 4 can interface using three different serial interfaces (SPI, I2C, and UART). The example reads in the time data from the RTC using I2C, then pulls the positioning data from the Joystick using the SPI interface, and then completes the example by sending the RTC value to hyperterminal and using the joystick to control where the RTC value is displayed on the screen.
While the example almost seems like a game, please step back and consider how this type of system dynamic would be common in an end design. We can imagine pulling in data from two separate inputs and having to relay those values up to a main host or PC. In many case the input data may affect other data and require some type of data manipulation.
Hardware Connections:
The user will need to populate and solder the 6 pin Pmod header to the Pioneer kit. This header will allow the user to connect the Pmod Joystick module. The SPI interface that reads the values from the joystick will be configured and set in the PSoC 4 project. There is already a physical connection between the Pmod module and the PSoC 4 device. The SPI pins on the PSoC 4 will be: P3[0], P3[1], P3[5], P0[6], and P0[7].
Next connect the Pioneer board to the Real Time Clock board. First connect the Vdd and GND lines from the Pioneer kit to the Clock board. Next connect your I2C lines from the Pioneer board to the Clock board. The I2C lines are: P4[0] and P4[1].
Also connect the PSoC 4 UART connections to the PSoC 5LP device so the UART positioning can be relayed up to the host.
PSoC 4 P3[7] -> P5LP P12[6]
PSoC 4 P0[5] -> P5LP P12[7]
Test Your Project:
After connecting your project please program the example into the PSoC 4 device. Once programmed then launch your Hyperterminal software to view the UART data traffic. Then use the joystick to control the output on the hyperterminal software.
I hope this example can help you in your design.
Best,
Matt