Error while programming Microchip ATTINY404

Thread Starter

AverageMoss

Joined Apr 24, 2021
34
I've been trying to learn how to program the Microchip Attiny404 but suddenly ran into an issue. I am programming it with the Atmel-ICE and suddenly every time I try to build and run on the Attiny404, I get an error message shown in the first screenshot:

Screenshot AVR Error.png

I'm fairly new to microcontrollers but not to programming in general, but I have no idea what this means, what's causing it, or how to fix it.
This is the schematic of how I have the Attiny404 wired up:

Screenshot Schematic.jpg

This is just a first prototype and I'm aware of the electrical mistakes. There is an external 5V power source wired to the microcontroller just so I would be able to learn to program it before building a new design.

I was able to run my program a couple of times before I just suddenly started getting this error.
If anyone can point me in the right direction that would be greatly appreciated!
 

Poyntat

Joined May 24, 2022
60
I notice that in your code snippet you are configuring PortA as output and then driving the outputs high then low.
As the UPDI is multiplexed on PortA.0, I wonder if this may have upset the Atmel-ICE if you left it connected when you ran the code.
 

Poyntat

Joined May 24, 2022
60
The TS stated that he was able to run the code a couple of times which implies that the device was programmed successfully at least once which suggests that the tool was happy with the device signature.
Try using different masks to the Direction and port registers that leaves PortA.0 in it’s reset state.
 

DickCappels

Joined Aug 21, 2008
10,068
Since that is the best idea we can come up with your @Poyntat must be worth a try. My experience with other AVR controllers, but using ISP, is that the Data Direction Registers have no effect on the programming signals during the programming process though heavy loading on the programming lines can prevent programming. Let's see whether you idea solves the problem and maybe look for new clues.

Just noticed that some I/O pins are driving relays without transient suppression on the coils - maybe just disconnecting the relay coils will allow things to start working.
 

Poyntat

Joined May 24, 2022
60
The 1 wire programming line (UPDI) seems a little more sensitive to external influences than the old ISP scheme that used MISO & MOSI and a separate reset line. I have had issues when loading the UPDI Pin with resistor Values as high as 47k and now I always discount using PortA.0 as GPIO.
@DickCappels is absolutely right about the need for suppression diodes across the relay coils but I’m assuming this is one of the electrical (scematic) mistakes you refer to in your text. If you drive the coils as per the schematic you will destroy the ATtiny.
 

Thread Starter

AverageMoss

Joined Apr 24, 2021
34
Thank you for your replies!

So I tried removing all the relays from the circuit and programming it again as @DickCappels suggested, but it made no difference.

I want to try what @Poyntat suggested but I don't know how and Google is not a good help. Here is what he suggested:
Try using different masks to the Direction and port registers that leaves PortA.0 in it’s reset state.
 

Poyntat

Joined May 24, 2022
60
Step 1. Remove connections between the relay coils and the ATtiny.
Step 2. Replace the ATtiny with a new, known good device.
Step 3. Change your initialisation in main to PORTA.DIR = 0xF0;
This will configure the upper pins of PortA as outputs and leave the others as inputs.
Step 4. Remove the statements within the while loop (just as a test).
So this becomes while(1){}
Compile and try programming.
If this doesn’t work you may have an issue with the Atmel ICE.
Running the original code without suppression diodes would have generated some very nasty voltage transients which could have punched through the ATtiny into the UPDI line and into the ICE.
Lets’s hope this is not the case.
 

Thread Starter

AverageMoss

Joined Apr 24, 2021
34
Thank you @Poyntat I replaced the microcontroller with a new one and removed the relays. Also updated the code and now I have no issues running my program. I guess the relays must have fried the microcontroller as you guys suggested.

Thanks again to all that commented!
 

Poyntat

Joined May 24, 2022
60
Good news!
If you are intending to build the hardware for your project think about introducing a buffer between the ATtiny port pins and the relay coils and of course include a suppression diode across each coil as mentioned.
The coils of those relays will draw around 30mA when energised and if I remember correctly the abs max for a port pin is 40mA, that would be too close for me!
 
Top