Wednesday, January 23, 2019

PSoC Creator SWD Debugging Failure

This article talks about Cypress' PSoC Creator SWD Debugging error often observed by the developers.

I am using PSoC Creator 4.2 for debugging one of the Cypress' PD Controller.

So, I have opened up the project and then select Debug option from the Debug menu.

The Creator is able to program the image and then the below error is thrown
PSoC Creator SWD Debug Error.
The output window displays the below text: Error: dbg.M0015: Debugger exited unexpectedly during run.  Encountered error (Target disconnected See output window for more information.)

One reason for this could be that the SWD pins are not configured for SWD purpose and being configured in GPIO mode.

To change the SWD configuration follow the below steps
  • Open the *.cydwr file to check the current configuration for the SWD pins.
  • Select the System tab in the *.cydwr file.
  • The reason for not able to debug that the Debug select option being set to GPIO instead of SWD.
  • While choosing between GPIO's on the controllers it could be best to leave these pins so that the debugging can be performed using SWD pins.


Let me know your feedback and suggestions.

Sunday, January 13, 2019

C Programming Language and for loop

C Programming language allows developers to write loops using for and while.

Consider the below C code in which for loop being used.
Code Snippet 1




In the above code the test expression uses two conditions with a comma separator.

Sometimes the developers might assume that the code in the for loop is not executed when any condition fails.But the for loop always executes when first condition is True or False and the Second condition is True. The for loop is exited when the Second condition Fails.

Hence the for loop exits when the loop value becomes 2 for the code in Code Snippet 1
Output for Code Snippet 1


Now, just interchange the two conditions and see the Result after executing the code.
Code Snippet 2  


Output for Code Snippet 2