AVR Chips and debugwire

I came across a problem where I was no longer able to program the AVR after enabling the debugwire. When debugging the software on your microcontroller, make sure to always stop the debugging session the correct way so that the debugwire fuse bit gets disabled. When you don’t do this you will lock yourself out of the chip and will no longer be able to read/write the devices signature or fuses.

If you have locked yourself out try the following. I have tried it with the AVR dragon and the JTAGICE mkII programmers using Atmel Studio 6.1

1: Hook back into the debugging session by opening a project and start debugging.

2: In the menu select Debug->Disable debugwire and close

You should now be able to read the device signature again!

Atmega32, !SS and SPI

Ran into some trouble trying to get the SPI interface to work on the Atmega32 micro controller. Sometimes, the interface would not work after a reset, It looked as if the interface just would not get initialized while my code looked fine.

After some investigation and debugging i found out that sometimes the MSTR bit would be cleared before the software could fully initialize the SPI interface. So i looked up the chapter on PSI in the datasheet to see if there was some special situation that could clear this bit. (more…)