You are here

Serial Wire View with PSoC 4 | Cypress Semiconductor

Serial Wire View with PSoC 4

[re-printed from iotexpert.com]

Self-confessed semiconductor geek and Roman historian, Darrin Vallis guest-blogs on Alan's iotexpert site about Arm's SWV feature.

I use PSoC 4 to invent all kinds of unique solutions for customers. Usually, they want them field upgradeable to deploy new features or fix bugs. Fortunately Cypress has a great I2C boot loader to meet this need, so I use the heck out of it.

Cypress has a great debugger built into PSoC Creator which fully supports all the Arm Serial Wire Debug protocols such as breakpoints, single step, memory, register viewing etc. However, when you are running a boot loader the debugger does not work! Why not? Because with a boot loader there are two applications resident in PSoC 4: The boot loader and application. This is not supported by Cypress implementation of SWD.

I2C Communication

Where does this leave you, the intrepid code developer, when debugging a boot loader project? Personally, I have used all kinds of methods: debug UART interface, debug I2C interface, bang out states on pins, debug Bluetooth interface … and on and on. You get the idea. All these methods burn a communications interface and require extra pins on the chip. Sometimes that’s not possible.

The issue recently came to a head when a customer very nearly in production experienced a boot loader failure. One system out of a few thousand was “bricked” when they tried to field  update in the lab. Their pinout is frozen, they can’t add new hardware so how do we look inside PSoC 4 and see what’s going on?

I woke up at 2 AM and thought “Ah Ha! SWV!” (Yes, I Am A Geek) Serial Wire View is an Arm native debug protocol that let’s you XRAY the insides of any Arm MCU with the right interface. SWV is a protocol which runs on the SWD pins (clock and data) but also needs the Serial Wire Output (SWO) pin. Cypress left the SWO pin and associated IP off of PSoC 4 to save die cost, foiling my great idea. Brief interlude to drink and bang head on desk.

ARM Coresight Achitecture

Fortunately, I don’t give up easily. At least my subconscious does not. Woke up the next night thinking “Ah Ha!” again. Wife was mildly annoyed, but tolerates my idiosyncrasies.

Cypress has a nice software UART transmitter implementation. I shamelessly stole it, modified for my purposes and created a custom component. (It’s pretty easy to do this by the way) Baud rate was modified to 230 KBps and the output pin forced to a specific pin with a control file.

Custom DTView component

Once the component is in place, you can use its _DView_Printf( ) API call to display any debug data. Here is an example:

DTView_Printf()

More about that output pin. Cypress sells a tool for programming and debugging PSoC called CY8CKIT-002, aka MiniProg3. The programming connector consists of VDD, GND, reset, SWD clock and SWD data as shown below.

Cypress Miniprog3 connections

Since we can’t use SWD protocol for debugging anyway, we can change the pins from SWD to normal GPIO. The pins still function for programming. By default they are in SWD mode as shown.

PSoC debug pins

Going to the system tab of the .CYDWR file, we can change them to GPIO.

PSoC debug pins reused as GPIO

Once we do that, the pins look like this. Here’s the trick. We now assign the TX output of our DTView component to pin 3[2], which is available on the SWD programming header, pin 5.

PSoC debug pins reused as GPIO

Can you see where we are going with this? Printf( ) data is now coming out of PSoC 4 on pin 3[2], easily accessible on our debug header. This is where MiniProg3 comes in. It can actually receive data as a 230 KBps RX UART on its XRES pin. Weird, right? By building a simple interface cable we can get the data from your debug header into MiniProg3.

MiniProg3 XRES —— SWD HEADER pin 5

MiniProg3   GND —— SWD HEADER pin 2

Hand-built SWV cable!

However, MiniProg3 does not show up as a COM port on your PC, so how do we the data? It needs to be accessed by a host application running the PP_COM API. This is documented under PSoC Programmer Component Object Model COM Interface Guide, Cypress specification 001-45209. If you installed PSoC Creator or Programmer, this document is actually on your PC under C:\Program Files (x86)\Cypress\Programmer\Documents. Engineers don’t like to read instructions. Amazing what you can find when you do.

I wrote a simple  console application which opens MiniProg3 using PP_COM, retrieves data from the serial RX pin via USB and displays it like a simple terminal program. Voila! You now have a serial debugger that works for any PSOC4 project using MiniProg3 as your USB to serial dongle.

Customer was really happy with this. We were able to immediately see his problem and fixed it in about 5 minutes.

DTViewer serial terminal emulator

Finally, here are all the source files

DTView Firmware : PSOC Creator example project and DTView component

DTViewer Binary : Installer for DTViewer console

ViewerSource : Complete source code for DTViewer console (Requires Visual Studio 2015)

That’s all. Have fun with the new debugging tool.

DTV

 

Blog: 

Comments

adamjones341_3098521's picture

The introduction of semiconductors changed the vision of the world. From semiconductors to transistors was a great phase. A small device that changed the entire world. It is worth to know the history of semiconductors before proceeding to transistors. The vision of people has been changed and thus we can't expect the future. Humans produced artificial humans, I mean Robots. The world has moved quickly so far and our vision goes endless.

Ask the research experts at essay writing service for more history.

nabeel_1522996's picture

why use a miniprog3 anyway? - can use a regular FTDI cable commonly used to snoop UART to a terminal like TeraTerm or whatever.

chriss lyn's picture

The latest news from Android however tells a different story about spotify. Recently, the company has blocked access to users who were using Spotify Premium APK without subscription. So, using Spotify is a bit difficult for users who got used for the free stuff.

abuse.twink_3225011's picture

One of the best features of your website is to freely express your thoughts. For this I really appreciate your blog 192.168.1.254

renukachouhan2015_2765426's picture

Provides multiple learning environment of International standard with holistic system of education at an affordable cost for the successful life of young generation.
Best Paramedical College North india
Best B.Ed. College in Dehradun
Top Agriculture college in Dehradun
Best BCA College in Dehradun

honeyjoshi0129_3268366's picture

The vision of people has been changed and thus we can't expect the future.

Pandora premium APK

Spotify Mod APK

Mod My Android

thalia.shalitta_3275356's picture

Bermain curang http://newtreatmentforhairloss.com/natural-cure-of-hair-loss/ dalam permainan poker http://newtreatmentforhairloss.com/reverse-hair-loss-program-does-it-work/ tentu saja dilarang http://familylifeandme.com/family-life/siblings-august-2016/ dan jika agen http://familylifeandme.com/collaborations/10-things-i-have-learnt-about-... online Indonesia http://aboutpokertables.com/poker-online-dewatapoker/ mengetahuinya, http://huntforyourinnerslut.com/dewa-poker-online-dewatapoker/ maka Anda bisa terkena http://thinkbigdigitalmarketing.com/dewa-poker/ sanksi hingga https://judiceme.co/cara-bermain-qq-poker-online/ pemblokiran akun sehingga Anda https://judiceme.org/qq-poker-online/ tidak bisa lagi menggunakan http://judidomino.info/qq-poker-online/ situs tersebut untuk bermain judi http://judicapsa.biz/tips-memainkan-poker-cc/. Namun bagaimana http://judidomino.biz/tips-memainkan-qqpoker/ jika trik licik bermain poker http://judidomino.co/cara-memainkan-99-poker/ tersebut tidak diketahui oleh agenhttp://judionline.co/tips-bermain-poker-cc-online/ ? Faktanya terdapat https://dominopoker.co/poker-online-pulsa/ banyak sekali tips http://gameqq.biz/tips-memainkan-poker-cc-indonesia/ untuk memenangkan https://gameqq.org/tips-permainan-99-poker-online/ poker dengan cara licik namun tetap dalam kondisi aman https://capsagaple.com/cara-memainkan-99-poker/.

Tips curang menang di https://capsaqqpoker.com/cara-bermain-99-poker/ agen poker online Indonesia

Menggunakan cara https://cemecapsa.com/tips-bermain-99-poker/ licik untuk memenangkan pertaruhan poker https://cemegaple.com/mengenal-lebih-99-domino-poker/ dalam agen poker online https://cemeqqpoker.com/99-domino-poker-online-uang-asli/ Indonesia banyak dilakukan pemain sebagai berikut:

Anda bisa membuat tiga https://gaplecapsa.com/99-domino-poker-online-uang-asli/ akun secara langsung dengan username https://gaplecapsa.com/99-domino-poker/ sekaligus akun bank yang berbeda https://gapleceme.com/99-domino-poker/. Untuk mengakalinya, Anda bisa meminjam identitas orang lain seperti teman atau keluarga https://gapleqqpoker.com/99-domino-poker/ Anda sehingga seolah-olah tiga akun tersebut dimiliki oleh http://siamadisurya.blogspot.com/ tiga orang yang berbeda https://kiucapsa.com/99-domino-poker/. Mungkin Anda akan berpikir https://kiugaple.com/99-domino/ apakah gunanya akun tersebut?

renukachouhan2015_2765426's picture

Students learn best when they actively participate in the lesson or that they feel valued when teachers encourage them to share their knowledge with their peers.

top cbse school in haryana

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.