PSOC And Logic Analyzers
Sometimes the code you put into the PSOC does not work. And you can’t figure out why. Single stepping it with a debugger looks good. But it does not work.
This problem has been around for a very long time. Many times we can cause the suspect code to repeat over and over. We then use an Oscilloscope to look at the repeating pattern to see if we can determine why it is not giving us the correct results. Sometimes that is not enough.
Enter Logic Analyzers.
Logic Analyzer History (Personal)
In the past decades, logic analyzers were very expensive and very big units. The earlier ones were on carts that rolled around. These units weighed 30 pounds or more. The user interface was clumsy, but they were able to catch signals that happened faster than 10 nanoseconds (100 MHz frequency). Today’s desktop and laptop computers have clock speeds 20 times faster than the signals they could capture.
As time went on, entrepreneurs realized the desktop computer could handle the Graphical User Interface, and the USB 2.0 interface could transfer data at 480 MHz (48 megabytes per second) under certain conditions. Speeds of 240 MHz were obtainable on a consistent basis. With some inexpensive hardware attached to the USB, a desktop version of a logic analyzer could be created that rivaled the 30 pound units. And they could capture data more than twice as fast as a 100 MHz signal, so they could handle information generated by embedded processors.
It is a truism that pioneers get shot in the back (with arrows). These early people, such as Saleae, had their hardware designs copied by Asian countries, (I am assuming after the patents expired), and their software escaped into the wild.
After a bit of time, Saleae gave up and designed more expensive units and put in some protection for their software. You can download the Saleae software that works with the $13 analyzer from them. I consider this an excellent advertising situation for them. Their hardware and software is first rate. I would suggest supporting them at work if you use their software.
Free (As in Beer) Software
In the meantime, the GPL software movement took hold, and PulseView was created. It can use these cheap logic analyzers. You can purchase the small logic analyzer in the photo above for as little as $13 (as of August 2022, expect the price to double soon). Look for HiLetGo. For that cheap, tiny unit shown above, select the fx2lafw (generic driver for FX2 based LAs). There are drivers for over 25 units, including LeCroy, Hantek, Saleae, etc., so don’t dismiss this program if you have a different unit lying around.
You can spend a little more money (around $40) and look for LHT00US1, which includes 2 analog channels. (It uses the same driver as the smaller L.A.)
For around $400, you can get a 1 GHz sampling rate and capture some signals around 500 MHz, or get a *lot* of definition for 100 MHz signals. Depending upon your logic analyzer, commercial software for Mac may not be available, but it will always be available for Windows. I have used Windows programs in a VM to talk to a USB logic analyzer connected to the Mac.
The PSOC Connection
A PSOC5 processor, which runs as fast as 67 MHz, but usually around 24 to 48 MHz, is in the sweet spot for cheap logic analyzers. I have used the $13 unit to debug 10 to 20 MHz signals coming to and from the MCU.
For this article, I loaded a blink LED program into a CY8CKit-059, and hooked up one of the 8 channel analyzers. (I have several. At that price, why not?)
In order to get the slow signal on the screen over a long period of time, with a reasonable amount of data transferred over the USB, I chose 1 million samples at a 250 KHz sampling rate. The PulseView application gave me the following picture. PulseView is free, at https://sigrok.org/wiki/PulseView.
I have Dark Mode turned on. With my 50+ years in front of a computer, my lenses are reflecting higher wavelength light, so a dark mode allows me to concentrate. I would have already taken care of this issue, but “pandemic.” They use a sledgehammer where a fly swatter would have worked.
As you can see from the timing above, the LED is on for 1/2 second, and off for 1/2 second.
Pulseview also has a lot of “decoders” so you can decode SPI bus, RS232, I2C, etc. These decoders, in my experience, work as well as the decoders on the $10,000+ analyzers.
Sometimes PulseView builds are unstable, so be sure to download different versions to get the one that works for you. (That is the thing about free software: It costs nothing, so there may not be very good Quality Control. Deal with it.)
I have used PulseView and the FX2 driver to capture signals at a 24 MHz sampling rate on my iMac. This has allowed me to look at 2 to 10 MHz communications protocols without issues. You could possibly see 12 MHz signals well enough to decode them, but for those experiences, I have personally used OpenBench (which may no longer be available.)