3

I came across something strange while reading the datasheet for the microcontroller in the Arduino Uno board.

It is the (8) note in pg.296-297 of this datasheet: what does WORDS mean in that context?

  • Daniel - I suggest that you change your acceptance to jwpat7's answer. | My answer is correct re address word BUT his points out that "Words" are being addressed and not bytes. While my answer is not wrong, his is more likely to be what the writer meant in his excessively cryptic footnote. – Russell McMahon Feb 6 '15 at 11:20
2

The notation is being used to indicate that the 16-bit address (as formed by the central bytes of a Write Program Memory Page instruction) is the address of a program-memory word, rather than a program-memory byte.

The size of program memory is specified in bytes, but it often is addressed as words. For example, the PC (program counter) register contains word addresses.

For some instructions, when the Z register is used to address program memory, it contains a word number and a byte selector:

The Z-register in the Register File is used to access the Program memory. This 16 bits register pair is used as a 16 bits pointer to the Program memory. The 15 most significant bits selects the word address in Program memory. Because of this, the word address is multiplied by two before it is put in the Z-register. ... The least significant bit of the Z Address Register selects either Low byte (0) or High byte(1) of the Program memory word. — AVR108: Setup and Use of the LPM Instruction, page 1

Note: Some of the low bits of the word address in a “Write Program memory page” serial programming instruction are treated as don't-cares. The number of don't-care bits depends on flash page size, which in Atmel AVR devices is 32, 64 or 128 words, depending on device series.

For example (as shown in Table 129 on page 304 of doc2467.pdf) the ATmega128 with 128-word (256-byte) flash pages has seven don't-care bits in the low byte of the address.

Table 129. SPI Serial Programming Instruction Set
                 -----------Instruction Format----------
 Instruction       Byte 1    Byte 2    Byte 3    Byte 4    Operation

Write Program    0100 1100 aaaa aaaa bxxx xxxx xxxx xxxx
Memory Page                                              Write Program Memory 
                                                         Page at address a:b.
  • Thanks for the answer! I tried to upvote, but I don't have 15 rep yet. Could you please take a look at the follow-up question I posted as a comment under Russell's answer? – Nubarke Feb 6 '15 at 10:42
  • I suspect your answer is closer to what is meant than mine. I'm not used to the specific hardware and your quoted passage suggests that your interpretation is superior. I don't just say "I'm wrong" (although I may be) as what I pointed out is correct per se - but Occcam's Razor says your answer should be chosen :-). – Russell McMahon Feb 6 '15 at 11:18
  • @DanielArmengod, I added a note re don't-cares in flash page addresses – James Waldby - jwpat7 Feb 6 '15 at 17:32
  • @jwpat7 Thank you so very much for the note you added afterwards! It helped me a lot. I'm trying to program an Arduino to serve as a programmer for other MCUs (now I'm targeting the same atmega328p from another Arduino, but my end-goal is (with the help of some external circuitry) to program a PIC18F. – Nubarke Feb 7 '15 at 20:00
3

See jwpat7's answer.
My answer is correct re address word BUT
his points out that "Words" are being addressed and not bytes. While my answer is not wrong, his is more likely to be what the writer meant in his excessively cryptic footnote.

A Byte is most usually used to refer to an 8 bit quantity.

A "word" is usually used to refer to a multi-Byte variable with the length depending on both processor type and context.

In this case, on page 296, table 28-19 information is given on the format of 4 byte Instructions. These instructions are NOT referred to as Words although in some other contexts they might be.

However, the "Write Program memory page" instruction contains the address of a memory page. This address is made up of a 16 bit field comprised of 2 Bytes - an MSB and an LSB.
The notation "Words" is shown against the MSB and the LSB to denote (not very clearly) that a single 16 bit "Address Word"is formed by the MSB + LSB combination.

enter image description here

  • I believe I understand what WORDS means in this context now. However, I have a new question: if the Write Program Memory Page instruction writes the page buffer to a page in the program Flash, why does it require the address of a program Word? – Nubarke Feb 6 '15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.