In PSOC Creator Debugging mode, is there a way to monitor the status of GPIO? Or the Port Registers, such as "Pin State" as defined in the pin header file?

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

cross mob
BrMa_1409086
Level 1
Level 1
First like received First like given

I have searched all over and cannot find a solid answer to this question. For example, using PSOC5LP and programming with PSOC Creator 4.0, when I enter debugging mode is there a way to watch the status of an input or output pin. For that matter, is there a way to watch the main port registers as defined in the pin header file. Assume an output pin is named "SO". The SO.h file contains a list of registers, such as Pin State, Data Register, etc. Is there a way to watch these values during debugging?

My current method is to simply Read the pin and update a global variable, but it seems like there should be a better way to do this. I am used to Code Composer Studio where you can look at all the port settings via drop-down menus and toggle GPIO values.

Thanks!

0 Likes
1 Solution

When you add a watchpoint, it is a variable watchpoint by default. Hence to set a watchpoint on a memory address you need to add a memory watchpoint.

To add a memory watchpoint:

Go to Debug > New Breakpoint > Memory Watchpoint

Then add the address you want to monitor and change "Break on" to Access instead of Write.

During debugging you can see the hit count of the Watchpoint increase on every access in the Breakpoints window.

In the memory window, type the specific address and then edit the corresponding values to toggle the value of the pin. Try it out and let us know your observations.

Regards,

Dheeraj

View solution in original post

0 Likes
7 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

You can Add WatchPoint during debug session on Read , Write and Access for the Port Registers

0 Likes

Hello Brody,

Taking your example given, you can see this register in SO.h file:

#define SO_PS                     (* (reg8 *) SO__PS)

If during debug, you right click this, are you not getting the option of "Add WatchPoint".I checked in Creator4.2. Presently, I don't have Creator4.0.

0 Likes

I do indeed get the "Add WatchPoint" option, but nothing really occurs beyond that. In the "Breakpoints" window, I can see a Variable Watchpoint has been added for that register, whether access, read or write.

However, the Hit Count always shows 0 and nothing occurs during debug.

What I am looking for is a method to review the state of port or gpio registers when I pause the debug execution. In CCS for example, I can pause the debug execution, and then review the current state of all registers in the system: GPIO state, GPIO direction, GPIO resistor enables, etc. Although this is not what I was asking, CCS allows the user to also edit register values during debug. For example, I can pause the debug execution, and manually toggle an output pin low and high. Or I can change the pin from output to input by changing the bit for that register.

Does PSoC Creator have similar functionality?

Thanks,

Brody

0 Likes

When you add a watchpoint, it is a variable watchpoint by default. Hence to set a watchpoint on a memory address you need to add a memory watchpoint.

To add a memory watchpoint:

Go to Debug > New Breakpoint > Memory Watchpoint

Then add the address you want to monitor and change "Break on" to Access instead of Write.

During debugging you can see the hit count of the Watchpoint increase on every access in the Breakpoints window.

In the memory window, type the specific address and then edit the corresponding values to toggle the value of the pin. Try it out and let us know your observations.

Regards,

Dheeraj

0 Likes

Thank you! This information helped answer the question. Actually, the breakpoint, while useful, doesn't really help my issue. However, knowing how to access the GPIO via the memory window does. This is the key, and for that you deserve the correct answer.

Simply because I found this process frustrating and assuming others will have a similar issue at some point, I would like to expand on this answer in specific relation to what I asked. Code Composer Studio has a built-in drop-down menu listing all core and peripheral registers. These registers are named and described clearly in the dropdown (i.e. Port_1_2>P1OUT0). There you can monitor or type in new values. That is what I am used to.

Now in PSOC Creator (4.2) the same result can be achieved through the Memory window, as ddka pointed out above. However the trick is finding the actual memory address. This may be obvious to more experienced users, but the file that contains all of the address values is  "cydevice_trm.h". Here you can look up the addresses for everything on the PSoC.

To be consistent with my initial question, here is my indirect method of getting to the same file from where I was stuck.

In a simple LED blink project PSOC5LP (CY8CKIT-059) LED 1 is connected to Pin 2.1. Assuming I named the GPIO "LED1" and defined it as an output, a folder will be created called "LED1" with the following files: "LED1.c", "LED1.h", and "LED1_aliases". In the LED1.h file, scroll down to the following line:

/* Data Register */

#define LED1_DR                     (* (reg8 *) LED1__DR)

I have not found a way to directly copy and paste that define statement into the "Address:" input of the Memory window.However, if you right-click on the "(* (reg8 *) LED1__DR)" portion, you can then select  "Go To Definition" or "Go To Declaration". This will open the cyfitter.h file and will highlight "#define LED1__DR CYREG_PRT2_DR". If you right-click on "CYREG_PRT2_DR" and select "Go To Definition", "cydevice_trm.h" opens and highlights "#define CYREG_PRT2_DR 0x40005120u". Copy and paste "0x40005120" in the address input and press enter.

The first column should start at 0x40005120. The next column over shows the 8-bit width register contents. If in HEX, a 0x02 (0b0000 0010) entered will turn the LED1 on, while a 0x00 will turn it off. From here, obviously, the pin state, etc. can also be modified. Also in the future, I will go directly to "cydevice_trm.h" file to look up memory addresses directly.

Also, I am now using PSoC Creator 4.2. There doesn't seem to be any difference with regard to the functionality in question.

0 Likes