Reading a page in the flash memory using inline assembly

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

I want to read a page in the program memory using inline assembly for 32KB microcontroller (Atmega328p). Since for MCUs that have memories larger than 64KB, RAMPZ has to be used. But what about small ones? Anyone tried to implement inline assembly version for reading a flash page in MCUs with memory less than 65KB? 


 

 

matsan

Last Edited: Sat. Oct 28, 2017 - 02:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why wouldn't you just use the existing pgm_read_*() routines? (or in this case pgm_read_*_far() ones).

 

Better yet the compiler now has __memx pointers so just read through one of those (23 bit addressing).

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

clawson wrote:

Why wouldn't you just use the existing pgm_read_*() routines? (or in this case pgm_read_*_far() ones).

 

Better yet the compiler now has __memx pointers so just read through one of those (23 bit addressing).

 

Because normally the code above is slightly faster than using the existing macros. 

matsan

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

Err no. You'll find that the access code for __memx is going to be equal or possibly better.