Electronic – the data register address for GPIO pin 21 Cortex ARM M0

armcortex-mreference

I need to find data register address for GPIO pin 21 Cortex ARM M0?

I feel this question can need some background. I am learning embedded MCU programming and most sources mention that I need to find the address for the particular port / pin. It seems like a basic thing to do (so basic, that it is not really covered how to do it)

I studied manuals / architecture reference for Cortex ARM M0 closely, but could not find anything that can point me to the address. All I see is range (in my case, I know the peripheral range is 0x40000000-0x5FFFFFFF).

Here is the link to technical reference manual:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0432c/DDI0432C_cortex_m0_r0p0_trm.pdf

Architecture reference:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0419b/index.html

Best Answer

You should probably just use the function provided in the header files.

#include <nrf_gpio.h>
nrf_gpio_cfg_output()
nrf_gpio_pin_set()
nrf_gpio_pin_clear()

If you want to see how the registers are defined, read the definitions of these functions in the header files.

There are some examples in the SDK, which I've ranted about before: http://markrages.tumblr.com/post/48981903493 Maybe the examples are better now.