What does n stand for in registers?

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

Hi! I am new to avr. In datasheets there is an "n" in all registers. What does it mean?

Avr

Last Edited: Wed. Oct 30, 2019 - 07:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It depends. For example, if you have several peripherals of the same type, like timers the datasheet will have stuff like OCRnA, meaning an instance of this this register exists in every timer; for timer 0 it will be OCR0A, for timer 1 it will be OCR1A, etc.

 

Another situation is the names of certain bits, like PINxn. Here the x stands for the port letter, e.g. A, B, C, etc. and the n is the bit number. So an actual bit would be for example PIND2.

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

You might want to give us an example of what you’re referring to.
My guess is if there is 32 registers, then ‘n’ is a number from 0 to 31.

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

But note that for something like LDI then Rn stands for just R16 to R31 (ie just 16 registers, not 32)

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

Oh, this is a First Post so kicka deserves a welcome to AVR Freaks. Hope your subsequent postings go a little smoother than this one!

 

Note that this is almost a classic case of "newbie unfamiliarity". Someone who first encounters TCNTn may not even know about assembler Rn and may not even have yet encountered PINxn. And, thus, may not even realize that here is something that requires a more explicit framing of the question beyond the generic "register".

 

Don't know how you get beyond this conundrum. It has a lot to do with how widely the term "register" is used in a variety of contexts.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Tue. Oct 29, 2019 - 10:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a good reference manual to get familiar with the AVR instructrions.   Note that "n" typically refers to a peripheral register selector

  (like OCRnA  such as OCR1A, OCR6A, whatever)

http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Isn't it curious how different people interrupt the word "registers" differently?

 

For me it means the 32 CPU registers R0..R31 which are oftend denoted Rn, Rn+1 and so on in the CPU opcode manual

 

Others see "registers" as "Special Function Registers" (SFRs) that control the peripherals like UCSRnA or TCNTnH

 

Guess we need to hear back from Kicka to know which context was meant.

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

UCSRnC – USART Control and Status Register n A/B/C. For example

Avr

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

The device might have more than one usart. Usart0, usart1 and so on. For all intents and purposes they are identical so it is expedient to use ‘n’ to refer to all of them.

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

Rather confusingly, when mega48/88/168 first came out (later followed by 328) they called the UART things like UCSR0A, UDR0 etc which suggests there might be UCSR1A, UDR1, etc but this devices still only have a single UART. It was simply future proofing for later devices that would have more than one.

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

Case in point: Mega328PB

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

It was simply future proofing

I wish Atmel spent more time proofreading than future-proofing. crying

===============

 

Atmel seem to use a loose, but useful, notation of "register"

mega48:  The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers,
SPI, and other I/O functions. The I/O Memory can be accessed directly, or as the Data
Space locations following those of the Register File, 0x20 - 0x5F.

There's also the Status Register

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!