Hello,
If you are taking medicines for depression , then depression itself can cause
erectile dysfunction. The other cause can be psychological reasons as you are getting good morning erections. Medications such as blood pressure medications (especially beta-blockers), heart medications (such as digoxin), some peptic ulcer medications, sleeping pills, and antidepressants may also cause erectile dysfunction. So check them out.
I hope it helps. Take care and regards.