The Master of a Million Disguises!

TopHAT with PSoC4.jpg

Figure 1. Initial PSoC4 tests using a CY8CKIT-049 4200 with the Compact TOP HAT with concurrent UART and I2C interfaces active.

(The blurry lead is a MiniProg3 used for single step debugging.)


My Compact HAT enables a PSoC to be easily connected.

The design has a PSoC connected to the Raspberry Pi's Serial Port, I2C, SPI port and some GPIOs.

The intention is to have;

  • SPI port as an interface option
  • I2C port as an interface option
  • Serial Port as an interface option or a program load interface for the PSoC
  • GPIOs as interrupt and auxillary inputs or outputs between the Raspberry Pi from the PSoC
  • The remaining PSoC pins remain free for the user's design


These are native interfaces with the Raspian and require very little configuration.

Although possible I did not consider using a parallel interface to the RPi because I did not have an immediate need for it and it required some LKM (Loadable kernel modules) written for it..


I could have laid out the prototype to include a PSOC but that would have tied me down to a single option. Instead I provided ordered connection points to provide more flexibility and choice such as using a PSoC5LP.

The CY8CKIT-049 42xx provides very easy access to its PSoC pins making it perfect for prototype development without the hassle of hand soldering TQFPs. It also allows a direct plug in connection for a MiniProg3 or other PSoC debugger.


Are you Serialous!

By default the Raspberry Pi's Serial port is assigned for use as a Console port. To use this port for your own purposes it is recommended that this assignment is removed otherwise you may get unwanted interaction (from the Console subsystem).

This is done quite easily by:

1. Editing the /etc/inittab file and commenting out the line containing /dev/ttyAMA0.

2. Granting users access to the serial port using sudo chmod 777 /dev/ttyAMA0.


Step 1. requires a reboot to take effect - so reboot your Raspberry Pi with sudo shutdown -r 0


Now with that done and dusted, you can log back in and now configure the Raspberry Serial Port's baud rate to suit your purpose.

This can be done by stty -F /dev/ttyAMA0 <baudrate>

So for a baud rate of 9600 baud it'll be stty -F /dev/ttyAMA0 9600


You can send out characters out the serial port using the following;

echo -n <character(s)> > /dev/ttyAMA0

So to send "Hello" you it'll be echo -n Hello > /dev/AMA0


You can read in characters in from the serial port using the following;

cat /dev/ttyAMA0


These can be observed on your trusty TEK TBS1052-EDU.


If you operate your PSoC at the same voltage as the Raspberry Pi then all you need to do is connect up the TX, RX and ground pins.

The COMPACT HAT has a pin header specifically for this purpose. Just connect a common ground and cross-connect the TX and RX pins to the PSoC


The choice is up to you as what to do with this serial port connection. It can be used with an application or it can be used as a bootloader to upload firmware into the PSoC.


Raspberry Pis are Slave Drivers!

The Raspberry Pi is configured as an I2C master so if it is used the PSoC can be configured as an I2C Slave.

The assigned I2C address for the PSoC base just needs to be compatible with other present I2C peripherals.

The process to create an I2C Slave on a PSoC is easy.

1. Create a new project

2. Plop on an I2C SCB component on the Schematic

3. Configure its I2C address

4. Write some code to initialise the I2C component and enable global Interrupts

5. Write some code to respond to I2C events such as receiving some data.

6. Assign the I2C component pins.


Not so you Loupy!

SPI is an alternative low cost serial communication bus to I2C and requires the use of some additional signal lines but has the advantage of much faster clock rates.

PSoC SCBs can be used as either UART, I2C or SPI peripherals so the choice is yours on how to use them.

In addition, PSoC also has UDB (Universal Digital Blocks) component counterparts that could be used.


Raspbian supports all these interfaces so there is plenty of flexibility of choice and easy programmatic access.