Last address in application section

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

I am using AT90USB1286. It has 128kB of flash memory. I am also using bootloader for which I've reserved 8kB. I want to find out what's the last address in which I can put value. Either my math or logic fails here - According the 1286 datasheet, start address for 8kB bootloader is 0x1FFE0, so that's 131040 in decimal.

 

128kB * 1024 = 131072 bytes

Bootloader start address is 131040? How is that possible?

 

Can somebody please clear this up for me? I want to understand memory addresses, and I also want to find out last available address in application area.

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

Just do the maths. 128K-8K = 120K. In decimal that is 120 * 1024 = 122,880. That is 0x1E000 or, as Atmel have a habit of using 16 bit word addressing (the granularity of the smallest AVR opcode in flash) it would be 0xF000.

 

You can see this in table 29-8 of the datasheet:

 

0xF000 is the entry point for the largest of the four settings for a USB128x chip. If you go for a 4K bootloader then your entry is 0xF800 which is 0x1F000 in bytes or 126,976 which is 124 * 1024 (leaving 4 * 1024 for the bootloader).

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

My bad - I used the wrong hex value for bootloader start address. Thanks! So in that case the last application address which I can safely use would be:

 

128kB - 8kB - 1 = 122879, or in hex: 1DFFF

 

Correct?

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

Yeah.

 

I think this is one occasion when it's easiest to work in decimal (at least at first). As I say 128K (chip) minus 8K (bootloader) is clearly 120K. So that is your boundary. 120K is 122,880 in decimal or 0x1E000 if you prefer. You can use every byte up to that address for the app (so the last one is 0x1E000 - 1 = 0x1DFFF) and every byte from there to 0x1FFFF for the bootloader.

 

All these numbers are in Atmel's table above - but because they use word addressing all the values are show as half the byte value. Also when they say a 0xF000 boot start so app is 0x0000..0xEFFF then when you double 0xEFFF you get 0x1DFFE but that really means 0x1DFFE *AND* 0x1DFFF as you can use both bytes at the 0xEFFF (word) location.

 

(Boy did Atmel ever complicate this when they chose to specify it all in terms of words!!)