Hi! I am new to avr. In datasheets there is an "n" in all registers. What does it mean?
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.
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.
But note that for something like LDI then Rn stands for just R16 to R31 (ie just 16 registers, not 32)
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 Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net
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)
When in the dark remember-the future looks brighter than ever. I look forward to being able to predict the future!
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.
UCSRnC – USART Control and Status Register n A/B/C. For example
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.
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.
Case in point: Mega328PB
It was simply future proofing
It was simply future proofing
I wish Atmel spent more time proofreading than future-proofing.
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
© 2019 Microchip Technology Inc.