In my previous column, I briefly introduced the PSoC (Programmable System-on-Chip) devices from Cypress Semiconductor.
The PSoC devices offer varying amounts of programmable analog and programmable digital fabric and memory. Members of the PSoC 1 family also include Cypress's proprietary 8-bit M8C processor core; members of the PSoC 3 family include an 8-bit 8051 core; members of the PSoC 4 family include a 32-bit ARM Cortex-M0 core; and members of the PSoC 5 family boast a 32-bit ARM Cortex-M3 core.
For my current project, I decided that a PSoC 4 would be able to offer all the capabilities and functions I require. With the aid of the PSoC 4 Pioneer Kit (Arduino shield compatible), I quickly established that the PSoC 4200 would meet my needs. Since this project was a rush job, I quickly committed to a PCB so that it could be produced in parallel with the rest of the development.
For maximum configurability, PSoC devices contain reconfigurable logic blocks called Universal Digital Blocks (UDBs). The PSoC 5 has up to 24 of these UDBs while the PSoC 4200 has 4 (the PSoC 4100 has none). In the PSoC 4, some of these UDBs are replaced with components that are not as configurable. In some cases, the I/O pins are proscribed, nudging this approach closer to a normal microcontroller. When comparing the PSoC 4 to the PSoC 5, in addition to the differences between the ARM Cortex M0 and M3, there are also differences with regards to the clock frequency, Flash, SRAM, and the speed of the peripherals like the ADC (analog-to-digital converter).
As a starting point for my project, I required a two-channel ADC. You can see its placement on the device schematic in Figure 1.
Figure 1. The ADC component has been placed and the input pins named and attached. Part of the configuration of the ADC options is shown here.
(Click here to see a larger image.)
My initial thought was that the IP block for the ADC on the PSoC 4 would be nominally the same as on the PSoC 5 (which I used for a previous project), but this was not the case. Cypress has rethought this and created the ADC block with quite a few nice touches. Even though there is only one ADC, it can be configured with up to four differential channels that will automatically sequence through their conversions (you can set delays on each conversion). Furthermore, you can build in averaging automatically, thereby saving you writing the code. Other IP components in the device show a similar flair.
In order to drive my bi-colored LEDs (as discussed in my previous blog) I needed a PWM controller, but I wanted to use a single PWM for both the red and green since I wasn't varying the shade of orange. I added a few logic gates as illustrated in Figure 2, and I had the functionality that I was looking for. You can't do that on many micros!
Figure 2. The output of the PWM is conditioned by the addition of two AND gates and a control register so that I can have blank, red, green, or orange, with the brightness being controlled by the PWM ratio. The second bi-color LED has another PWM controller configured in exactly the same way.
(Click here to see a larger image.)
After I had realized this approach, I was looking at the different components (in the form of IP configurations) and came across a device called a PrISM (Precision Illumination Signal Modulation) which had two PWM outputs and the ability to independently control them, which is pretty much had what I had set up. It also has a pseudo random PWM variation to reduce EMI noise. Unfortunately, this is where I bumped into having laid out the PCB beforehand. There weren't enough resources to allow me to use the PriSM and the SPI controller and some other components that I had selected. If I had laid out the PCB for the fixed output pin version of the SPI, everything would have been fine. It would have been nice to use the PrISM, but not using it wasn't a show-stopper.
To Page 2 >