Real Time Trace: SWV(Serial wire viewer) in PSoC3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

   

To start with SWV in PSoC3/5LP :-      

   

Serial Wire Viewer (SWV):  Single Wire Viewer (SWV) interface, is used for program and data monitoring, where the firmware may output data in a method similar to “printf” debugging on PCs, using a single pin (P1[3]/SWO). MiniProg3 supports monitoring of PSoC 3 and PSoC 5LP firmware, using SWV, through the 10-pin connector (or SW0 and ground) and in conjunction with SWD only.     

   

Benefits:      

   

It is a run time debugger. You can print the values of the variables in run time like “printf” statement.     

   

SWV Data trace is available via the SWO pin in two output formats:     

   
        
  • UART style (1Mb/s) – Advantage is no need of RS232 connector and not using PSoC’s UART block. In a big project, where UART is needed and still needs to know the values of variables, SWV is the best approach.      

  •     
  • Manchester Encoded (100Mb/s) – You can use this if high data rate is required.      

  •    
   

     

             

   

How to use this application:      

   

The attachment contains a project and application for SWV interface. Program the PSoC with this project. Then connect SWO pin /P1[3] and ground pin of PSoC to corresponding pins in MiniProg3 or connect MiniProg to PSoC via 10 pin connector(JTAG cable).      

   

Pre Requisites:      

   

1.      PSoC creator      

   

2.      PSoC programmer 3.18.1      

   

If you are using any other version of PSoC Programmer, then copy the PP_Com_Wrapper.dll from the installed location and paste where the application is present.      

   

Open the application “MiniProg3_SWV” in the attached document.      

   

Select the protocol that you have selected in the firmware. And start the operation.

   

      

 If the selected data is 1 byte and data is i=0,i++, then 01 00 01 01 01 02 01 03.. Here indicates the size of the received data and 07, 08.. indicates the data that has been sent.      

   

Similarly, if  the selected data size is 2 bytes, then the received data will look like 02 01 00 02 02 00.. Here 02 is data size and 0001 is data ( LSB then MSB) .      

   

Similarly, if the selected data size is 4 bytes, then the received data will look like 03 01 00 00 00 03 02 00 00 00.. Here 03 is data size and 00000001 is data ( LSB then MSB) .      

   

Hence you can place this piece of code in any of your project and can monitor the variables.

   

We have tested this only in PSoC3.

   

      

 

   

Thank You,

   

 

   

Keerthi 

7 Replies
Anonymous
Not applicable

Hello,

   

Ment to say, if the data is i=0 and i++ and i is 1 byte of data, the output would look like 01 00 01 01 01 02 01 03 01 04 ... if it is a infinite loop. Here 01 is size of data since it is 1 byte and 01, 02 ,03 ,04.. which are present alternatively are actual data.

   

Thank You,

0 Likes
Anonymous
Not applicable

Good stuff. Need something like this to debug some communication issues. Shall try it today 🙂

0 Likes
VlYe_281166
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello,

   

MiniProg3_SWV.exe does not run under Windows 7 x64.

   

Any ideas?

0 Likes
Anonymous
Not applicable

OK, I took the C# SWV app and modified it to make it more useful. I added buttons to connect/disconnect the Miniprog3 (and select voltage and connector). I also changed the app to just print ascii characters from the SWV stimulus port (not ascii hex representations).

   

I also created a PSoC Creator firmware example that redirects printf() to the SWV stimulus port 0. The firmware works both on PSoC3 and PSoC5. 

   

So what you get is a little app that lets you connect and view SWV printf() console output from the Miniprog3!

   

The app is usable, but can stand to have a lot more refinement. Because of this, I have put the code on github. I'm hoping some of you can try it out and perhaps even make some contributions.

   

https://github.com/kyoung2112/csharp-miniprog3-swv

   

https://github.com/kyoung2112/psoc_creator_swv_firmware

   

(Oh, and this is my first use of github, and I'm relatively new to git in general, so please be gentle if I screwed something up!)

   

Regards.
Kris

   
        
0 Likes
Anonymous
Not applicable
        Thanks for posting the app. Very useful for fast debug output. Is there a doc that describes the PP_ComLib_WrapperClass API? Also interested in the format of the data passed to pp_USB2IIC_ReceivedData. Timestamp etc.   
0 Likes
Anonymous
Not applicable
        Having this functionality will help greatly with debugging; however it isn't working for me.   
I'm using the CY8CKIT-010 with the MiniProg3 connected from the Aux port to the PROG port... it appears that the _write function isn't getting called, but I know that the hardware is working because the following in main() works:   
   
int debug_printf(const char *format, ...)   
{   
int i, len;   
char output[200];   
   
   
va_list args;   
va_start(args,format);   
len = vsprintf(output, format, args);   
va_end(args);   
   
char* ptr;   
ptr = output;   
for (i = 0; i < len; i++)   
{   
while (CY_GET_REG8(CYDEV_ITM_BASE) == 0);   
CY_SET_REG8(CYDEV_ITM_BASE,*ptr++);   
}   
return len;   
}   
   
int main(void)   
{   
uint32 i;   
   
SWV_1_Start();   
   
while (1)   
{   
debug_printf("Here\n");   
CyDelay(1000);   
}   
}   
0 Likes
AnGi_1678941
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

Is there something similar for PSoc6?

0 Likes