Scared about sex

I'm 26 weeks My husband and I  have not had sex for 3 weeks because before that I started having cramping and pelvic pain dr said I was fine baby was good but I was still scared so I gave in and we had sex this morning but I'm scared because it was sooooo painful and now I'm cramping can anyone help I think this was seriously the last time till after I deliver