I had a 330i ZHP for a few years and it wasn't outrageous to maintain. The typical issues are pretty well documented at this point (I assume the E39 would be the same way). If you stay on top of it, it's fine. I had one nagging issue: a vacuum leak that I finally tracked down but was far too big of a hassle to fix.
I owned it from 45,000 to around 70,000 miles. Keep in mind both are getting up there in age. I'd want to be safe and keep some cash on hand. I can't speak for the 540 but would guess it's pretty similar in terms of maintenance costs.