Basic Question about PORT Registers definition

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All,

I apologize in advance for a very basic stuff to ask, but I just started with Atmel and I am kind of lost about where to find some guidance.

I work with SAD21 Xplained Pro MCU evaluation board. My project consists of reading 16 input bits, and then according to their values, create some outputs, and I am looking for some kind of tutorial to begin with learning.

 

My question is: Where can I learn how to use "port.h" file in my code, that is, what all those registers do, and how and when are they used. For example:

 

REG_PORT_OUTSET0                   (0x41004418) /**< \brief (PORT) Data Output Value Set 0 */
REG_PORT_OUTSET1                   (0x41004498) /**< \brief (PORT) Data Output Value Set 1 */

REG_PORT_OUTCLR1                   (0x41004494) /**< \brief (PORT) Data Output Value Clear 1 */

REG_PORT_OUTCLR0                   (0x41004414) /**< \brief (PORT) Data Output Value Clear 0 */

I understand (possibly wrongly):

REG_PORT_OUTSET1 sets the value of the output bit.

REG_PORT_OUTCLR1 resets the value of output bit.

But then what REG_PORT_OUTSET0 and REG_PORT_OUTCLR0 do? 

So, in this nerve, I would like to learn more about other registers in "port.h".

Last Edited: Tue. Nov 13, 2018 - 07:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely those are simply register addresses so *(uint32_t *)REG_PORT_OUTSET0 = 0xBABEFACE; would write that value to the register?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And it doesn't matter what values I write to what register and how I use them after? I guess I am confused about why are they named like that then.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The registers are described in the datasheet. What you might be missing is 

Each line bundle with up to 32 lines is assigned an identifier 'xy', with letter x=A, B, C… and two-digit number y=00, 01, …31. Examples: A24, C03.

It's this grouping (of up to 32 pins) that is the numeric suffix on the REG_PORT register definitions (0 for A, 1 for B etc).  This grouping is also visible when using the struct definitions, e.g.,

PORT->Group[0].DIRSET.reg = PORT_PA22;

PORT->Group[1].DIRCLR.reg = PORT_PB11;

Plenty of threads here on the subject btw.

/Lars