Programming Fuse/Lock Bits Messes Up Code Execution

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

I've noticed when I program the fuse/lockbits to not allow further read/writes, programming, etc... that my code becomes all glitchy & does not run properly. When I re-load my program & do not set these fuses everything is fine again. Set the fuses, and everything glitches up again... Am I doing something wrong? I'm using an ATMega644, compiling with WinAVR, and my program size is up to 96% full (63112 bytes). RAM is at 89% full and EEPROM at 76%. I'm just quoting those figures in case I'm using too much memory to set the fuses or something?

Thanks in advance for any ideas...

James

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

Can you define "glitchy" and provide us with the specific lockbits you are setting?

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

Hi James,

If you are using the selfprogramming feature (SPM and LPM) and at the same time set the bootloader lock bits this might result in the behaviour you are seeing. Please make sure that you read the 'Memory Programming' --> 'Lock Bits' section in the datasheet and understand how your changes will affect the behaviour of MCU. E.g. if you set the lock bits in a way that disables LMP from accessing the application section of the flash and you try to use the LMP instruction this will not work and the rsult will be the same as executing a 'NOP' instruction.

If I understand you correctly the program works correctly if you reprogram and do not set the lock bits (not the fuses), so it seems very likely that this issue is related to the lock bits settings beeing wrong wrt what you are trying to do in your code.

Sletten

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

Okay, I mis-spoke slightly... I only had the problems when programming the lockbits, not the fusebits. I just noticed that if I do not set the bootloader lockbits at your suggestion (and set the LB and BLB0 ones only) the program runs fine. Thanks for those comments Sletten. I'm kind of clueless as to how this all works... do not even know what a bootloader is... just wrote a long program that I wanted to give some amount of protection to. Anyway, thank you very much for your fast reply & very helpful comments. They were greatly appreciated!

- James