Flash read incorrectly with lpm

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

Hey guys, in one of my programs, i need to read the my program in the flash memory. its really simple and i have done it earlier: generally i use the following code:

lpm tr,z+
call transmit ; transmits the contents of tr via uart

But this time it just doesnt read correctly. it returns 0xff. I know there is something other than ff coz i read it from ponyprog.
This happens to the starting section of flash. If i set the z pointer to point to my bootloader, it reads that properly.
I've tried this for different atmega16s and that is not a problem.
Anyone ever come across this problem?

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

ok got it.. i didnt mention that i was writing a bootloader.
So i forgot to enable reading in rww section of flash after programming.
Now it's working