You can see most of Trondheim in a day. The highlight is the cathedral, which is a big stone cathedral with lots of stonework and that looks like most cathedrals in mainland Europe. The open-air Sverresborg Trøndelag Folkemuseum is nice, but I wouldn't say it's an amazing must-see unless you were already in Trondheim.
Bergen is home to the famous UNESCO-listed Bryggen waterfront, and the Hanseatic Museum does a great job of explaining the Hanseatic trading history. It's also interesting just to wander through the Bryggen to see the modern companies that have set up offices in these historic buildings. There are some other historic sites related to the time in the area and a museum dedicated to the Bryggen, though I've never been in during any of my trips to Bergen. The fish market nearby is a fun place to stop for a snack, and there are great views from the top of the Fløibanen funicular. There's also some great hiking in the hills around the city. Gamle Bergen is a small open-air museum but the English guided tour was interesting. There also Edvard Grieg's estate at Troldhaugen (pretty grounds) and Ole Bull's Lysøen (haven't been, but it looks gorgeous). And if you've managed to get through all of that, there's also a natural history museum with a menagerie of stuffed creatures and whale skeletons and some art museums and concert halls. I'd skip the aquarium, which I found to be overpriced and generally disappointing.
Oh, and you can do a cruise down the Sognefjord from Bergen (or a Nutshell-style trip to Flåm and Nærøyfjord).
Just to double check most things (shops, restaurants, etc...) in Bergen will be closed Sundays, right? Just trying to figure out if we should take the 9am flight or the 5pm flight home.
I vote Bergen but that is just because I live here and it is gorgeous at the moment. Restaurants will be open on Sunday and I would guess that some of the stores on Bryggen will also be open on Sunday (they definitely are during tourist season).
The "fish market" has been moved into an ugly building near its the old location and I would give it a pass. There may well be stands in the old position (there's been talk about getting rid of those because they are apparently an eyesore).
If it is decent weather, you'll definitely want both days.
If you like hiking, there are a lot of easily accessible and beautiful hikes in the area.