You are here

Serial Wire View with PSoC 4 | Cypress Semiconductor

Serial Wire View with PSoC 4

[re-printed from]

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:


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.





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

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 dalam permainan poker tentu saja dilarang dan jika agen online Indonesia mengetahuinya, maka Anda bisa terkena sanksi hingga pemblokiran akun sehingga Anda tidak bisa lagi menggunakan situs tersebut untuk bermain judi Namun bagaimana jika trik licik bermain poker tersebut tidak diketahui oleh agen ? Faktanya terdapat banyak sekali tips untuk memenangkan poker dengan cara licik namun tetap dalam kondisi aman

Tips curang menang di agen poker online Indonesia

Menggunakan cara licik untuk memenangkan pertaruhan poker dalam agen poker online Indonesia banyak dilakukan pemain sebagai berikut:

Anda bisa membuat tiga akun secara langsung dengan username sekaligus akun bank yang berbeda Untuk mengakalinya, Anda bisa meminjam identitas orang lain seperti teman atau keluarga Anda sehingga seolah-olah tiga akun tersebut dimiliki oleh tiga orang yang berbeda Mungkin Anda akan berpikir 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

본 사이트의 모든 컨텐츠와 자료는 "있는 그대로" 제공됩니다. CYPRESS SEMICONDUCTOR와 해당 공급자는 그 목적에 관계 없이 이러한 자료의 적합성에 대한 표현을 하지 않으며 상업성, 특정 목적에의 적합성, 권리 및 제3자 지적 재산권의 비침해에 대한 모든 묵시적 보증과 조건을 포함하여(이에 제한되지 않음) 이러한 자료와 관련한 모든 보증과 조건을 부인합니다. CYPRESS SEMICONDUCTOR에서는 명시적 또는 묵시적으로 금반언이나 여타의 다른 방법으로 라이센스를 부여하지 않습니다. 이 사이트의 정보를 사용하려면 제3자의 라이센스 또는 CYPRESS SEMICONDUCTOR에서 제공하는 라이센스가 필요할 수 있습니다.

이 사이트의 컨텐츠에는 특정 사용 지침이나 제한이 포함되거나 그러한 제한이 적용될 수 있습니다. 모든 게시물과 이 사이트 컨텐츠 사용에는 사이트 약관이 적용됩니다. 이 컨텐츠를 사용하는 제3자는 제한 또는 지침을 따르고 이 사이트의 약관을 준수할 것이라는 데 동의합니다. Cypress Semiconductor와 그 공급자는 컨텐츠와 자료, 그 제품, 프로그램 및 서비스를 언제든 수정, 삭제, 개조, 개선, 향상 및 기타 변경하거나 예고 없이 컨텐츠, 제품, 프로그램 또는 서비스를 이동 또는 중단할 수 있는 권리를 보유합니다.