-1

Is ATmega32 an 8-bit or 16-bit microcontroller?

While reading Mazidi's AVR book it was stated that RAMEND in ATmega32 is at 0x085f which is a 16-bit address. Extract from the book here.

bruno
  • 105
  • 5
Ahmed Adel
  • 51
  • 5
  • 2
    It's an 8-bit CPU. The "ramend" value you've quoted is irrelevant. http://www.atmel.com/devices/atmega32.aspx – Ross Ridge Feb 19 '17 at 23:49
  • i think u miss the point this code is atmega32 code to set the stack pointer. – Ahmed Adel Feb 19 '17 at 23:56
  • he use a 16-bit address – Ahmed Adel Feb 19 '17 at 23:57
  • it is defined in header file that provided by atmel company . that ramend is 0x085f – Ahmed Adel Feb 19 '17 at 23:59
  • 3
    **You** miss the point. It's a 8 bit cpu, but that doesn't mean it can't have more than 256 bytes of memory, or that it can't process larger values. – Jester Feb 19 '17 at 23:59
  • Most 8-bit CPUs use 16-bit addresses. Lots of things are defined in headers provided by Atmel, that does't make them relevant. More relevant is the fact that Atmel describes the ATmega32 as being an 8-bit processor, as shown by the link I provided above. That means it has 8-bit registers and an 8-bit ALU. – Ross Ridge Feb 20 '17 at 00:02
  • The whole "n-bit CPU" naming was always a bit hazy, and more like marketing thing, than real HW state (except probably some very early prototypes which were really 4/6/8 bit in everything). The size of "general purpose registers" from the answer is reasonable way to categorize them, but I'm sure you would be able to find some CPU breaking even this rule. – Ped7g Feb 20 '17 at 13:13
  • Related: https://electronics.stackexchange.com/questions/57950/how-can-8-bit-processor-support-more-than-256-bytes-of-ram/383253#383253 – bruno Dec 12 '19 at 19:29

1 Answers1

6

The cpu is 8-bit, because the general purpose registers are 8-bit registers.

There are some 16-bit registers, e.g., the stack pointer SP, and the program counter PC. But they have to be larger because the address space is more than 256 bytes long.

We still say the cpu is 8-bit because the general purpose registers perform 8-bit operations.

UncleO
  • 8,299
  • 21
  • 29
  • you mean that this snap of code is right . there is some 16-bit reg although the micro-controller is 8-bit – Ahmed Adel Feb 21 '17 at 18:40
  • Yes, and can be registers even larger than 16-bit. Some AVR devices have so much flash program memory that 16 bits in the PC are not enough to address them all, so there is an extended portion as well besides HI and LO. But generally speaking, when people say "registers" they mean the general purpose registers used in the math operations. Technically, SP, PC, and STATUS are registers, too, but these are not the registers we are talking about. – UncleO Feb 21 '17 at 19:04
  • 2
    As well, there are some 16-bit general purpose registers, X, Y, and Z. But these are actually just names for pairs of 8-bit registers, and not independent 16-bit registers on their own. They are often used in address-based instructions. – UncleO Feb 21 '17 at 19:06
  • 1
    To complement UncleO's valuable answer I suggest reading the answers from [this](https://electronics.stackexchange.com/questions/57950/how-can-8-bit-processor-support-more-than-256-bytes-of-ram/383253#383253) post, where further information about the relationship between memory size and register "size" is given. – bruno Dec 12 '19 at 19:34