This content has been marked as final. Show 5 replies
For accessing a C variable in assembly, you have to add an underscore before the variable. The code should be
Some more points to remember.
1. The variables in PSoC Designer are in Big Endian format. So, to increment the LSB of seconds, use [_seconds + 3]
2. If you are dealing with a device with more than 256 bytes of RAM, you may also have to set the CUR_PP register to point to the currect RAM page. Check out the document on Large Memory model in the Help >> Documentation section of PSoC Designer for details about.
I've got to look in to the CUR_PP register stuff because although it compiles it doesn't seem to be incrementing the seconds variable.
There is one more approach you can try. This is to define the variable in assembly and then access it in C. You can place the variable in RAM Page-0 so that inside the interrupt, you do not have to change the CUR_PP register. Below is the procedure.
1. In the Timer ISR, define the variable like this.
seconds: BLK 4
This will place the seconds variable in Page-0. Make sure that you place the above instructions inside the custom user code area in the Timer's ISR file
2. To access this variable from a C file, add the following declaration either in a header file that is included in the source file or directly in the source file
extern long seconds;
Now you can access the seconds variable in C as well. Also, as the variable is now placed in Page-0 and as all the memorey operations are by default done on Page-0 inside an interrupt, you can access the variable inside the ISR without changing the CUR_PP register.
That works a treat, thanks!
You are most welcome