ATMEGA162 will not self-program (nothing no page erase nada)

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

I'm a veteran AVR Freak who uses self-programming in the smaller tiny's without hickup.

Now I move into a 162 and want to self program using the BSL. Set the BSL to 0x1C00 (0xE00 word) for powerup.

If I say to erase a page at 0x0000 byte address then read the address back, it remains whatever it was. I set the page to 00's or 69's or anything and it's always what it was :-(.

Has anyone seen this issue? I'm running INTRC at 8 Mhz, 3.3v. I even tried 5v and slowing down the INTRC to the slowest (writing OSCCAL to 0x00).

Here's an example of a page-erase from page 226 of the ATMEGA162/V manual (2513F-AVR-12/03)

ldi a, (1<<PGERS) | (1<<SPMEN)
out SPMCR, a
spm
ret

I did copy the "DoSPM" routine to check first if the SPMEN was busy but it doesn't make a difference.

BSL mode is enable with bootup to 0x1C00 as explained above.

Any insight??

Regards

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

lock bits?

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

nope. they are clear in unlocked position. I'm ready to try the mega8515 to see if I have similar problems.

thx!

Regards

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

Are you writing FROM the bootloader section?

(SPM only works from the bls, I don't know much about tiny's, but maybe most of them don't have bls and can SPM from anywhere)

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

Dang it! I got it guys.

Thanks CurtVm!

I was placing code at 0xE00 word thinking 0x1C00 was byte address.

So, code por is 0x1C00 WORD not byte. So darn confusing!!!

Somehow chip still powered up when I stuck the code at 0xE00. I guess 0xFFFF is a nop and PC wrapped around and hit my code start.

lol!

Regards

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

Even when you know about it, the word/byte thing can get you messed up sometimes.

At least the SPM problem pointed you in the right direction.

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

Yep, I can't believe they got me. I guess I was thinking 8k when I was dealing with 16k.

Regards