I had a few years ago 'burn-out'.
Even that I didn t have a depression my doctor gave me anti-dep's.
Now I know that I just needed a break, but I took those anti-dep's for more than 3 months.
In my burn-out, I wasn t interested in sex, let us say in nothing, I just wanted to be alone - but everyone round me thought that I sat deep. It wasn t so, I needed some rest.
The burn-out was over after 6 weeks and I was at 99% for work, and it gave me more energy, but it took me a year, regaining or maintaining an erection. ( due to those anti-dep's, my opinion )
The best advice that my doctor gave me - was quitting smoking. I smoked more than an half packet a day ( in Belgium 25 sig's in a packet )
The viagra did a thing, but with the so many side effects, I quitted the pill after 3 or 5 tries.
I'm 54years, and this happened to me several years ago.
And think... every man over 30 has sometimes ED, at 40 more, and at 50 it's more than 1 on 10 that the erection won't happen, even that you are very eroused.
A bridge-friend of me, same age, had prostate cancer, he's lucky that he can have 1 or 2 full erection a year. ( and we laugh then - because than just his wife isn't around )
Don't get fixated on your erection - sex is more... than a hard dick.
ED can happen at any age, but the older you get... Just enjoy sex, even without an erection.