As Diane suggests, consult with Legal Aid.
I don't know the regulations pertaining to Portland and I'm not a lawyer, so take with a grain of salt what follows. Still . . .
1) It's possible for the city to declare the apartment you're living in to be in non-compliance with its regulations. In a case like that, they'd typically go after the owner, requiring the owner to cease renting the noncompliant unit. So, while they wouldn't be evicting you, the end result would be the same. You'd have to move. It doesn't matter whether you pay your own electric, phone, cable, etc. The question is whether the apartment can legally be rented as a separate room. And I don't know the answer to that.
2) It's probably legal for a landlord to charge rent for an illegal unit. And while ignorance of the law is no excuse, maybe he thought the unit was legal. And you apparently thought it was, too. And, after all, it's his property. More to the point, if you find out it's a noncompliant unit--no, you can't stay there and not pay rent. If I were the owner and the city told me that I couldn't rent the basement apartment, I'd get you out as quickly as the law allowed. After all, he'd be continuing to break the law if he permitted you to stay.
You're in a potentially difficult spot. If you are in a noncompliant unit, then you probably should move. Certainly if the city finds out, you may have to move. You might be able to buy a little bit of time, but likely that's a few days or a week or two . . . not months. The landlord might be given the option by the city to bring the unit into compliance--if that's possible. But then the question is whether he's able to do so. Smoke detectors are easy. Providing a new exit . . . not so much, especially if the window measurements don't qualify as an exit.
Again, as Diane suggested, check with Legal Aid.