EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Spontaneous erasure of AVR working as SPI slave

Started by wzab January 12, 2011
Hi,
I'm using an ATmega32U2 uC as an SPI slave. Namely it receives
the I2S data stream sent to the DA1134F DAC in the AUREL's
audio link
( http://aurelwireless.com/rf-wireless-modules/product-info.asp?id=303
,
http://aurelwireless.com/rf-wireless-modules/product-info.asp?id=302 )

However once, when I pressed RESET button to enter the
DFU bootloader and update the firmware, I've stated, that the
bootloader does not exist any more.
I've connected the chip to the SPI programmer, and found,
that bootloader is erased and even the fuse bits were changed.

Analyzing the incident, I've stated, that probably I've pressed
the RESET when the SCK line (connected to the BCLK line
of I2S interface) was low. The ADC input data have accidentally
formed the valid serial programming command, and caused
erasure of firmware.

The above scenario may happen in any system which uses the AVR
as SPI slave, in which the SPI signals are still active when
AVR is reset. So probably it would be good to disable SPI
programming in such situation.
That workaround could be good for parts with JTAG programming,
but would be probably unconvenient for small AVRs without JTAG
(like ATmega88).

The above problem is easy to predict (basing on documentation),
but in fact I was quite surprised when it happened.
Therefore I wanted to report it as a caution.

--
Regards,
WZab
( wzab@ise.pw.edu.pl )

PS. The part of the code in ATmega88 version used to receive
one channel of I2S data with the SPI interface is published
on alt.sources with subject "Code for ATmega88 to receive
I2S data (one channel) at 24bit/48kHz ").

The 2024 Embedded Online Conference