11 years ago.

access to status register

In the C compiler, is there a way to access the status register of the processor? With AVR you can access the status flag with the SREG register (s=SREG). Is there something like that for the mbed C compiler?

Maybe you should mention why you need the status register. There might be better ways to achieve your goal.

posted by Igor Skochinsky 29 Mar 2013

2 Answers

11 years ago.

Interesting question. So I decided to search a bit around. In the LPC1768 (I assume you mean that one), after some searching I found the register name(s): http://www.nxp.com/documents/user_manual/UM10360.pdf, section 34.3.1.3.5.

So APSR is the one you probably want (or one of his friends). So I checked LPC17xx.h, and nop, not to be found there. Next option: google. And a general google on APSR and LPC1768 actually returned the mbed site: http://mbed.org/users/screamer/code/mbed/file/5364839841bd/LPC1768/GCC_ARM/core_cmFunc.h

So TL;DR:

__get_APSR()

is probably the function you want. It does indeed compile, you may check if it does what it should do ;).

sam white
poster
11 years ago.

Actually...I only have one kl25z...do you think the register will work for the kl25z.?

That is relevant information :P

But it turned out to not be too bad, same file is also in the KL25 code: http://mbed.org/users/mbed_official/code/mbed-Freescale/file/d5f2f3e8f628/cmsis/KL25Z/core_cmFunc.h, with same functions. It also makes sense since that register belongs to the standard ARM core. Guess both the M3s and M0s have it with the same name, so yes, it should work also for the KL25Z :)

(Luckily I could find it in the LPC1768 user manual, many vendors, including Freescale, could learn alot from NXP about creating datasheets/user manuals).

posted by Erik - 29 Mar 2013