- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any way to read the Program Counter value of a particular point in my code? I want to store this value in a varaiable and process it. (specifically for PSoC3).
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Program Counter register addresses can be found from PSoC3 Registers TRM.(Link:http://www.cypress.com/?rID=37833). But this register cannot be accessed using CY_GET_REG API's. It can be accessed only when CPU is in halt state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Program Counter register addresses can be found from PSoC3 Registers TRM.(Link:http://www.cypress.com/?rID=37833). But this register cannot be accessed using CY_GET_REG API's. It can be accessed only when CPU is in halt state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another method for reading the value will be using assembly instructions. These steps can be used to read the Program Coounter Value.
1)Use LCALL. When LCALL is use
2)Use POP instruction to read
3)Store the DPH DPL values to
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While adding assebly instructions,please refer the knowledge base article available in the link : http://www.cypress.com/?rID=43621
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please check the code snippet given below. Please add the same in your project. The Program Counter Value corresponding to the label here: will be stored in the variable ProgramCounterValue.
uint16 ProgramCounterValue;
/*---- This assembly code will store the Program Counter value to the variable ProgramCounter----- */
#pragma asm
LCALL here
here:
POP DPH1
POP DPL1
MOV DPTR, #ProgramCounterValue?040
MOV A, DPH1
MOVX @DPTR, A
INC DPTR
MOV A, DPL1
MOVX @DPTR, A
#pragma endasm
/*----End of the assembly block ------ */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The above attached project will print the Program Counter value on the LCD Screen.